Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-08-19 03:06:52
Exec Total Coverage
Lines: 8343 12146 68.7%
Functions: 93 126 73.8%
Branches: 5463 10305 53.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include "base/qrs.h"
15 #include "base/cpool.h"
16 #include "base/packfile.h"
17 #include "base/dmap.h"
18 #include "base/combo.h"
19 #include "base/msgstr.h"
20 #include <filesystem>
21 #include <stdio.h>
22 #include <string.h>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <assert.h>
27 #include <fmt/format.h>
28
29
30 #include "metadata/sigs/devsig.h.sig"
31 #include "metadata/sigs/compilersig.h.sig"
32 #include "metadata/versionsig.h"
33 #include "base/zc_alleg.h"
34 #include "base/zdefs.h"
35 #include "base/colors.h"
36 #include "tiles.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "defdata.h"
40 #include "subscr.h"
41 #include "font.h"
42 #include "zc/replay.h"
43 #include "zc/zc_custom.h"
44 #include "sfx.h"
45 #include "md5.h"
46 #include "zinfo.h"
47 #include "zc/ffscript.h"
48 #include "particles.h"
49 #include "dialog/alert.h"
50 #include "base/misctypes.h"
51
52 #ifdef __EMSCRIPTEN__
53 #include "base/emscripten_utils.h"
54 #endif
55
56 //FFScript FFCore;
57 extern FFScript FFCore;
58 extern ZModule zcm;
59 extern zcmodule moduledata;
60 extern uint8_t __isZQuest;
61 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
62 extern particle_list particles;
63 extern void setZScriptVersion(int32_t s_version);
64 //FFSCript FFEngine;
65
66 int32_t temp_ffscript_version = 0;
67 static bool read_ext_zinfo = false, read_zinfo = false;
68 static bool loadquest_report = false;
69 static char const* loading_qst_name = NULL;
70 static byte loading_qst_num = 0;
71
72 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
73 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
74
75 #ifdef _MSC_VER
76 #define strncasecmp _strnicmp
77 #endif
78
79 #ifndef _AL_MALLOC
80 #define _AL_MALLOC(a) _al_malloc(a)
81 #define _AL_FREE(a) _al_free(a)
82 #endif
83
84 using std::string;
85 using std::pair;
86
87 // extern bool debug;
88 extern int32_t hero_animation_speed; //lower is faster animation
89 extern std::vector<mapscr> TheMaps;
90 extern std::vector<word> map_autolayers;
91 extern zcmap *ZCMaps;
92 extern byte *colordata;
93 //extern byte *tilebuf;
94 extern tiledata *newtilebuf;
95 extern byte *trashbuf;
96 extern itemdata *itemsbuf;
97 extern wpndata *wpnsbuf;
98 extern comboclass *combo_class_buf;
99 extern guydata *guysbuf;
100 extern ZCHEATS zcheats;
101 extern zinitdata zinit;
102 extern char palnames[MAXLEVELS][17];
103 extern int32_t memrequested;
104 extern char *byte_conversion(int32_t number, int32_t format);
105 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
106 string zScript;
107 116 std::map<int32_t, script_slot_data > ffcmap;
108 116 std::map<int32_t, script_slot_data > globalmap;
109 116 std::map<int32_t, script_slot_data > genericmap;
110 116 std::map<int32_t, script_slot_data > itemmap;
111 116 std::map<int32_t, script_slot_data > npcmap;
112 116 std::map<int32_t, script_slot_data > ewpnmap;
113 116 std::map<int32_t, script_slot_data > lwpnmap;
114 116 std::map<int32_t, script_slot_data > playermap;
115 116 std::map<int32_t, script_slot_data > dmapmap;
116 116 std::map<int32_t, script_slot_data > screenmap;
117 116 std::map<int32_t, script_slot_data > itemspritemap;
118 116 std::map<int32_t, script_slot_data > comboscriptmap;
119 void free_newtilebuf();
120 bool combosread=false;
121 bool mapsread=false;
122 bool fixffcs=false;
123 bool fixpolsvoice=false;
124
125 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
126 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
127 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
128 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
129
130 char qstdat_string[2048] = { 0 };
131
132 static zinfo* load_tmp_zi = NULL;
133
134 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
135 const byte clavio[9]={97,109,111,110,103,117,115,0};
136
137 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
138 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
139
140 const char *qst_error[] =
141 {
142 "OK","File not found","Invalid quest file",
143 "Version not supported","Obsolete version",
144 "Missing new data" , /* but let it pass in ZQuest */
145 "Internal error occurred", "Invalid password",
146 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
147 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
148 };
149
150 //for legacy quests -DD
151 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
152 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
153 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
154 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
155 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
156 };
157
158 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
159
160
161 void delete_combo_aliases()
162 {
163 for(int32_t j(0); j<256; j++)
164 {
165 if(combo_aliases[j].combos != NULL)
166 {
167 delete[] combo_aliases[j].combos;
168 combo_aliases[j].combos=NULL;
169 }
170
171 if(combo_aliases[j].csets != NULL)
172 {
173 delete[] combo_aliases[j].csets;
174 combo_aliases[j].csets=NULL;
175 }
176 }
177
178 }
179
180 char *byte_conversion(int32_t number, int32_t format)
181 {
182 static char num_str[40];
183
184 if(format==-1) //auto
185 {
186 format=1; //bytes
187
188 if(number>1024)
189 {
190 format=2; //kilobytes
191 }
192
193 if(number>1024*1024)
194 {
195 format=3; //megabytes
196 }
197
198 if(number>1024*1024*1024)
199 {
200 format=4; //gigabytes (dude, what are you doing?)
201 }
202 }
203
204 switch(format)
205 {
206 case 1: //bytes
207 sprintf(num_str,"%db",number);
208 break;
209
210 case 2: //kilobytes
211 sprintf(num_str,"%.2fk",float(number)/1024);
212 break;
213
214 case 3: //megabytes
215 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
216 break;
217
218 case 4: //gigabytes
219 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
220 break;
221
222 default:
223 abort();
224 break;
225 }
226
227 return num_str;
228 }
229
230 1624 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
231 {
232 static char num_str1[40];
233 static char num_str2[40];
234 static char num_str[80];
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1624 times.
1624 if(format1==-1) //auto
237 {
238 1624 format1=1; //bytes
239
240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1624 times.
1624 if(number1>1024)
241 {
242 1624 format1=2; //kilobytes
243 1624 }
244
245
2/2
✓ Branch 0 taken 1160 times.
✓ Branch 1 taken 464 times.
1624 if(number1>1024*1024)
246 {
247 464 format1=3; //megabytes
248 464 }
249
250
1/2
✓ Branch 0 taken 1624 times.
✗ Branch 1 not taken.
1624 if(number1>1024*1024*1024)
251 {
252 format1=4; //gigabytes (dude, what are you doing?)
253 }
254 1624 }
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1624 times.
1624 if(format2==-1) //auto
257 {
258 1624 format2=1; //bytes
259
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1624 times.
1624 if(number2>1024)
261 {
262 1624 format2=2; //kilobytes
263 1624 }
264
265
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 1508 times.
1624 if(number2>1024*1024)
266 {
267 1508 format2=3; //megabytes
268 1508 }
269
270
1/2
✓ Branch 0 taken 1624 times.
✗ Branch 1 not taken.
1624 if(number2>1024*1024*1024)
271 {
272 format2=4; //gigabytes (dude, what are you doing?)
273 }
274 1624 }
275
276
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 464 times.
✗ Branch 4 not taken.
1624 switch(format1)
277 {
278 case 1: //bytes
279 sprintf(num_str1,"%db",number1);
280 break;
281
282 case 2: //kilobytes
283 1160 sprintf(num_str1,"%.2fk",float(number1)/1024);
284 1160 break;
285
286 case 3: //megabytes
287 464 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
288 464 break;
289
290 case 4: //gigabytes
291 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
292 break;
293
294 default:
295 abort();
296 break;
297 }
298
299
2/5
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1508 times.
✗ Branch 4 not taken.
1624 switch(format2)
300 {
301 case 1: //bytes
302 sprintf(num_str2,"%db",number2);
303 break;
304
305 case 2: //kilobytes
306 116 sprintf(num_str2,"%.2fk",float(number2)/1024);
307 116 break;
308
309 case 3: //megabytes
310 1508 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
311 1508 break;
312
313 case 4: //gigabytes
314 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
315 break;
316
317 default:
318 abort();
319 break;
320 }
321
322 1624 sprintf(num_str, "%s/%s", num_str1, num_str2);
323 1624 return num_str;
324 }
325
326 char *ordinal(int32_t num)
327 {
328 static const char *ending[4] = {"st","nd","rd","th"};
329 static char ord_str[8];
330
331 char *end;
332 int32_t t=(num%100)/10;
333 int32_t n=num%10;
334
335 if(n>=1 && n<4 && t!=1)
336 end = (char *)ending[n-1];
337 else
338 end = (char *)ending[3];
339
340 sprintf(ord_str,"%d%s",num%10000,end);
341 return ord_str;
342 }
343
344 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
345 {
346 int32_t ret;
347 *version=0;
348 *build=0;
349 byte temp_map_count=map_count;
350 byte temp_midi_flags[MIDIFLAGS_SIZE];
351 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
352
353 zquestheader tempheader;
354
355 if(!f)
356 {
357 return qe_invalid;
358 }
359
360 ret=readheader(f, &tempheader);
361
362 if(ret)
363 {
364 return ret;
365 }
366
367 map_count=temp_map_count;
368 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
369 *version=tempheader.zelda_version;
370 *build=tempheader.build;
371 return 0;
372 }
373
374
375 bool find_section(PACKFILE *f, int32_t section_id_requested)
376 {
377
378 if(!f)
379 {
380 return false;
381 }
382
383 int32_t section_id_read;
384 bool catchup=false;
385 word dummy;
386 byte tempbyte;
387 char tempbuf[65536];
388
389
390 switch(section_id_requested)
391 {
392 case ID_RULES:
393 case ID_STRINGS:
394 case ID_MISC:
395 case ID_TILES:
396 case ID_COMBOS:
397 case ID_CSETS:
398 case ID_MAPS:
399 case ID_DMAPS:
400 case ID_DOORS:
401 case ID_ITEMS:
402 case ID_WEAPONS:
403 case ID_COLORS:
404 case ID_ICONS:
405 case ID_INITDATA:
406 case ID_GUYS:
407 case ID_MIDIS:
408 case ID_CHEATS:
409 break;
410
411 default:
412 al_trace("Bad section requested!\n");
413 return false;
414 break;
415 }
416
417 dword section_size;
418
419 //section id
420 if(!p_mgetl(&section_id_read,f))
421 {
422 return false;
423 }
424
425 while(!pack_feof(f))
426 {
427 switch(section_id_read)
428 {
429 case ID_RULES:
430 case ID_STRINGS:
431 case ID_MISC:
432 case ID_TILES:
433 case ID_COMBOS:
434 case ID_CSETS:
435 case ID_MAPS:
436 case ID_DMAPS:
437 case ID_DOORS:
438 case ID_ITEMS:
439 case ID_WEAPONS:
440 case ID_COLORS:
441 case ID_ICONS:
442 case ID_INITDATA:
443 case ID_GUYS:
444 case ID_MIDIS:
445 case ID_CHEATS:
446 catchup=false;
447 break;
448
449 default:
450 break;
451 }
452
453
454 while(catchup)
455 {
456 //section id
457 section_id_read=(section_id_read<<8);
458
459 if(!p_getc(&tempbyte,f))
460 {
461 return false;
462 }
463
464 section_id_read+=tempbyte;
465 }
466
467 if(section_id_read==section_id_requested)
468 {
469 return true;
470 }
471 else
472 {
473 //section version info
474 if(!p_igetw(&dummy,f))
475 {
476 return false;
477 }
478
479 if(!p_igetw(&dummy,f))
480 {
481 return false;
482 }
483
484 //section size
485 if(!p_igetl(&section_size,f))
486 {
487 return false;
488 }
489
490 //pack_fseek(f, section_size);
491 while(section_size>65535)
492 {
493 pfread(tempbuf,65535,f);
494 tempbuf[65535]=0;
495 section_size-=65535;
496 }
497
498 if(section_size>0)
499 {
500 pfread(tempbuf,section_size,f);
501 tempbuf[section_size]=0;
502 }
503 }
504
505 //section id
506 if(!p_mgetl(&section_id_read,f))
507 {
508 return false;
509 }
510 }
511
512 return false;
513 }
514
515
516
517
518
519 bool valid_zqt(PACKFILE *f)
520 {
521
522 //word tiles_used;
523 //word combos_used;
524 //open the file
525 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
526 if(!f)
527 return false;
528
529 //for now, everything else is valid
530 return true;
531
532 /*int16_t version;
533 byte build;
534
535 //read the version and make sure it worked
536 if(!p_igetw(&version,f))
537 {
538 goto error;
539 }
540
541 //read the build and make sure it worked
542 if(!p_getc(&build,f))
543 goto error;
544
545 //read the tile info and make sure it worked
546 if(!p_igetw(&tiles_used,f))
547 {
548 goto error;
549 }
550
551 for (int32_t i=0; i<tiles_used; i++)
552 {
553 if(!pfread(trashbuf,tilesize(tf4Bit),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the combo info and make sure it worked
560 if(!p_igetw(&combos_used,f))
561 {
562 goto error;
563 }
564 for (int32_t i=0; i<combos_used; i++)
565 {
566 if(!pfread(trashbuf,sizeof(newcombo),f))
567 {
568 goto error;
569 }
570 }
571
572 //read the palette info and make sure it worked
573 for (int32_t i=0; i<48; i++)
574 {
575 if(!pfread(trashbuf,newpdTOTAL,f))
576 {
577 goto error;
578 }
579 }
580 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
581 {
582 goto error;
583 }
584 for (int32_t i=0; i<MAXLEVELS; i++)
585 {
586 if(!pfread(trashbuf,PALNAMESIZE,f))
587 {
588 goto error;
589 }
590 }
591
592 //read the sprite info and make sure it worked
593 for (int32_t i=0; i<MAXITEMS; i++)
594 {
595 if(!pfread(trashbuf,sizeof(itemdata),f))
596 {
597 goto error;
598 }
599 }
600
601 for (int32_t i=0; i<MAXWPNS; i++)
602 {
603 if(!pfread(trashbuf,sizeof(wpndata),f))
604 {
605 goto error;
606 }
607 }
608
609 //read the triforce pieces info and make sure it worked
610 for (int32_t i=0; i<8; ++i)
611 {
612 if(!p_getc(&trashbuf,f))
613 {
614 goto error;
615 }
616 }
617
618
619
620 //read the game icons info and make sure it worked
621 for (int32_t i=0; i<4; ++i)
622 {
623 if(!p_igetw(&trashbuf,f))
624 {
625 goto error;
626 }
627 }
628
629 //read the misc colors info and map styles info and make sure it worked
630 if(!pfread(trashbuf,sizeof(zcolors),f))
631 {
632 goto error;
633 }
634
635 //read the template screens and make sure it worked
636 byte num_maps;
637 if(!p_getc(&num_maps,f))
638 {
639 goto error;
640 }
641 for (int32_t i=0; i<TEMPLATES; i++)
642 {
643 if(!pfread(trashbuf,sizeof(mapscr),f))
644 {
645 goto error;
646 }
647 }
648 if (num_maps>1) //dungeon templates
649 {
650 for (int32_t i=0; i<TEMPLATES; i++)
651 {
652 if(!pfread(trashbuf,sizeof(mapscr),f))
653 {
654 goto error;
655 }
656 }
657 }
658
659 //yay! it worked! close the file and say everything was ok.
660 pack_fclose(f);
661 return true;
662
663 error:
664 pack_fclose(f);
665 return false;*/
666 }
667
668 bool valid_zqt(const char *filename)
669 {
670 PACKFILE *f=NULL;
671 bool isvalid;
672 int32_t error;
673 f=open_quest_file(&error, filename, false);
674
675 if(!f)
676 {
677 // setPackfilePassword(NULL);
678 return false;
679 }
680
681 isvalid=valid_zqt(f);
682
683 clear_quest_tmpfile();
684 pack_fclose(f);
685
686 // setPackfilePassword(NULL);
687 return isvalid;
688 }
689
690 static std::string tmp_file_name;
691 258 void clear_quest_tmpfile()
692 {
693
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
258 if(tmp_file_name.size())
694 {
695 if(exists(tmp_file_name.c_str()))
696 delete_file(tmp_file_name.c_str());
697 tmp_file_name.clear();
698 }
699 258 }
700 /*
701 .qst file history
702
703 .qst files have always been compressed using allegro's packfiles.
704
705 At some point, an encoding layer was added. The two layers look like this:
706
707 1) The top layer is from us. See decode_file_007.
708 [0-24] Preamble "Zelda Classic Quest File"
709 [25-28] Initial decoding seed value.
710 [29-X] Allegro-encoded payload (AKA "packed" file)
711 [last 4] Checksum
712
713 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
714 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
715 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
716 The oldest quests skip the password part.
717
718 Simply, the job of this function is to peel away the top layer.
719
720 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
721 in opening and saving files. There is no version field, so they decryption key is
722 found via trial-by-error (very slow!)
723
724 There are other file types of interest:
725 - .zqt: quest template files, skips top-layer encryption pass
726 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
727 - .qu?: same as above. automated backup files
728 - .qb?: same as above. automated backup files
729 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
730
731 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
732 files are now "slh!.AG ZC Enhanced Quest File".
733 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
734 */
735 129 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
736 {
737
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (show_progress)
738 {
739 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
740 }
741
742 #ifdef __EMSCRIPTEN__
743 if (em_is_lazy_file(filename))
744 {
745 em_fetch_file(filename);
746 }
747 #endif
748 129 clear_quest_tmpfile();
749 // Note: although this is primarily for loading .qst files, it can also handle all of the
750 // file types mentioned in the comment above. No need to be told if the file being loaded
751 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
752 129 bool top_layer_compressed = false;
753 129 bool compressed = false;
754 129 bool encrypted = false;
755
756 // Input files may or may not include a top layer, which may or may not be compressed.
757 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
758 // with an allegro packfile password (longtan).
759 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
760 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
761 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
762
763 129 bool id_came_from_compressed_file = false;
764 129 const char* packfile_password = "";
765 char id[32];
766 129 id[0] = id[31] = '\0';
767 129 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
768
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (!pf)
769 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
770
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (pf)
771 {
772 126 id_came_from_compressed_file = true;
773
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (!pack_fread(id, sizeof(id)-1, pf))
774 {
775 pack_fclose(pf);
776 Z_message("Unable to read header string\n");
777 return nullptr;
778 }
779 126 pack_fclose(pf);
780 126 }
781 else
782 {
783 3 FILE* f = fopen(filename, "rb");
784
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
785 {
786 *open_error=qe_notfound;
787 return nullptr;
788 }
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
790 {
791 fclose(f);
792 Z_message("Unable to read header string\n");
793 return nullptr;
794 }
795 3 fclose(f);
796 }
797
798
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
129 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
799 {
800 // The given file is already just the bottom layer - nothing more to do.
801 // There's no way to rewind a packfile, so just open it again.
802
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (id_came_from_compressed_file)
803 {
804 126 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
805 }
806 else
807 {
808 return pack_fopen_password(filename, F_READ, "");
809 }
810 }
811
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
812 {
813 3 top_layer_compressed = id_came_from_compressed_file;
814 3 compressed = true;
815 3 encrypted = true;
816 3 }
817 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
818 {
819 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
820 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
821
822 char tmpfilename[L_tmpnam];
823 std::tmpnam(tmpfilename);
824 FILE* tf = fopen(tmpfilename, "wb");
825 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
826
827 int c;
828 while ((c = pack_getc(pf)) != EOF)
829 {
830 fputc(c, tf);
831 }
832 fclose(tf);
833 pack_fclose(pf);
834
835 tmp_file_name = tmpfilename; //store so it can be cleaned up later
836
837 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
838 // We should put qsu in the dat file, or use a separate .qst file for new qst.
839 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
840 }
841 else
842 {
843 // Unexpected, this is going to fail some header check later.
844 }
845
846 // Everything below here is legacy code - recently saved quest files will have
847 // returned by now.
848
849 char tmpfilename[L_tmpnam];
850 3 temp_name(tmpfilename);
851 char percent_done[30];
852 3 int32_t current_method=0;
853
854 PACKFILE *f;
855 3 const char *passwd= encrypted ? datapwd : "";
856
857 // oldquest flag is set when an unencrypted qst file is suspected.
858 3 bool oldquest = false;
859 int32_t ret;
860
861
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
862 {
863 3 box_out(filename);
864 3 }
865 else
866 {
867 box_out("new quest"); // Or whatever
868 }
869 3 box_out("...");
870 3 box_eol();
871 3 box_eol();
872
873
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
874 {
875 3 box_out("Decrypting...");
876 3 box_save_x();
877 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
878
879
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
880 {
881 switch(ret)
882 {
883 case 1:
884 box_out("error.");
885 box_eol();
886 box_end(true);
887 *open_error=qe_notfound;
888 return NULL;
889
890 case 2:
891 box_out("error.");
892 box_eol();
893 box_end(true);
894 *open_error=qe_internal;
895 return NULL;
896 // be sure not to delete tmpfilename now...
897 }
898
899 if(ret==5) //old encryption?
900 {
901 current_method++;
902 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
903 box_out(percent_done);
904 box_load_x();
905 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
906 }
907
908 if(ret==5) //old encryption?
909 {
910 current_method++;
911 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
912 box_out(percent_done);
913 box_load_x();
914 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
915 }
916
917 if(ret==5) //old encryption?
918 {
919 current_method++;
920 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
921 box_out(percent_done);
922 box_load_x();
923 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
924 }
925
926 if(ret==5) //old encryption?
927 {
928 current_method++;
929 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
930 box_out(percent_done);
931 box_load_x();
932 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
933 }
934
935 if(ret)
936 {
937 oldquest = true;
938 passwd="";
939 }
940 }
941
942 3 box_out("okay.");
943 3 box_eol();
944 3 }
945 else
946 {
947 oldquest = true;
948 }
949
950 3 box_out("Opening...");
951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
952
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
953 {
954 if((compressed==1)&&(errno==EDOM))
955 {
956 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
957 }
958
959 if(!f)
960 {
961 if(!oldquest)
962 {
963 delete_file(tmpfilename);
964 }
965 box_out("error.");
966 box_eol();
967 box_end(true);
968 *open_error=qe_invalid;
969 return NULL;
970 }
971 }
972
973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
974 {
975 3 delete_file(tmpfilename);
976 3 }
977
978 3 box_out("okay.");
979 3 box_eol();
980
981 3 return f;
982 129 }
983
984 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
985 {
986 char *filename;
987 PACKFILE *f=NULL;
988 int32_t open_error=0;
989
990 strcpy(qstdat_string, "modules/classic/default.qst");
991 if(Header->templatepath[0]==0)
992 {
993 filename=(char *)malloc(2048);
994 strcpy(filename, qstdat_string);
995 }
996 else
997 {
998 // TODO: should be safe to remove this, no one seems to use custom quest templates.
999 filename=Header->templatepath;
1000 }
1001
1002 f=open_quest_file(&open_error, filename, false);
1003
1004 if(Header->templatepath[0]==0)
1005 {
1006 free(filename);
1007 }
1008
1009 if(!f)
1010 {
1011 return NULL;
1012 }
1013
1014 if(validate)
1015 {
1016 if(!valid_zqt(f))
1017 {
1018 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1019 pack_fclose(f);
1020 clear_quest_tmpfile();
1021 return NULL;
1022 }
1023 }
1024
1025 return f;
1026 }
1027
1028 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1029 {
1030 // We absolutely do not support loading from a template file to initialize data outside the editor.
1031 // TODO: move this code into zq/
1032 if (get_app_id() != App::zquest) return false;
1033
1034 combosread=false;
1035 mapsread=false;
1036 fixffcs=false;
1037
1038 switch(section_id)
1039 {
1040 case ID_RULES:
1041 case ID_STRINGS:
1042 case ID_MISC:
1043 case ID_TILES:
1044 case ID_COMBOS:
1045 case ID_CSETS:
1046 case ID_MAPS:
1047 case ID_DMAPS:
1048 case ID_DOORS:
1049 case ID_ITEMS:
1050 case ID_WEAPONS:
1051 case ID_COLORS:
1052 case ID_ICONS:
1053 case ID_INITDATA:
1054 case ID_GUYS:
1055 case ID_MIDIS:
1056 case ID_CHEATS:
1057 case ID_ITEMDROPSETS:
1058 case ID_FAVORITES:
1059 break;
1060
1061 default:
1062 return false;
1063 break;
1064 }
1065
1066 int32_t ret;
1067 word version, build;
1068 PACKFILE *f=NULL;
1069
1070 char deletefilename[1024];
1071 deletefilename[0]=0;
1072
1073 //why is this here?
1074 /*
1075 if(colordata==NULL)
1076 return false;
1077 */
1078
1079 //setPackfilePassword(datapwd);
1080 f=open_quest_template(Header, deletefilename, validate);
1081
1082 if(!f) //no file, nothing to delete
1083 {
1084 // setPackfilePassword(NULL);
1085 return false;
1086 }
1087
1088 ret=get_version_and_build(f, &version, &build);
1089
1090 if(ret||(version==0))
1091 {
1092 pack_fclose(f);
1093 clear_quest_tmpfile();
1094
1095 if(deletefilename[0])
1096 {
1097 delete_file(deletefilename);
1098 }
1099
1100 // setPackfilePassword(NULL);
1101 return false;
1102 }
1103
1104 if(!find_section(f, section_id))
1105 {
1106 al_trace("Can't find section!\n");
1107 pack_fclose(f);
1108 clear_quest_tmpfile();
1109
1110 if(deletefilename[0])
1111 {
1112 delete_file(deletefilename);
1113 }
1114
1115 //setPackfilePassword(NULL);
1116 return false;
1117 }
1118
1119 switch(section_id)
1120 {
1121 case ID_RULES:
1122 //rules
1123 ret=readrules(f, Header);
1124 break;
1125
1126 case ID_STRINGS:
1127 //strings
1128 ret=readstrings(f, Header);
1129 break;
1130
1131 case ID_MISC:
1132 //misc data
1133 ret=readmisc(f, Header, Misc);
1134 break;
1135
1136 case ID_TILES:
1137 //tiles
1138 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1139 break;
1140
1141 case ID_COMBOS:
1142 //combos
1143 clear_combos();
1144 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1145 combosread=true;
1146 break;
1147
1148 case ID_COMBOALIASES:
1149 //combos
1150 ret=readcomboaliases(f, Header, version, build);
1151 break;
1152
1153 case ID_CSETS:
1154 //color data
1155 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1156 break;
1157
1158 case ID_MAPS:
1159 //maps
1160 ret=readmaps(f, Header);
1161 mapsread=true;
1162 break;
1163
1164 case ID_DMAPS:
1165 //dmaps
1166 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1167 break;
1168
1169 case ID_DOORS:
1170 //door combo sets
1171 ret=readdoorcombosets(f, Header);
1172 break;
1173
1174 case ID_ITEMS:
1175 //items
1176 ret=readitems(f, version, build);
1177 break;
1178
1179 case ID_WEAPONS:
1180 //weapons
1181 ret=readweapons(f, Header);
1182 break;
1183
1184 case ID_COLORS:
1185 //misc. colors
1186 ret=readmisccolors(f, Header, Misc);
1187 break;
1188
1189 case ID_ICONS:
1190 //game icons
1191 ret=readgameicons(f, Header, Misc);
1192 break;
1193
1194 case ID_INITDATA:
1195 //initialization data
1196 ret=readinitdata(f, Header);
1197 break;
1198
1199 case ID_GUYS:
1200 //guys
1201 ret=readguys(f, Header);
1202 break;
1203
1204 case ID_MIDIS:
1205 //midis
1206 ret=readtunes(f, Header, tunes);
1207 break;
1208
1209 case ID_CHEATS:
1210 //cheat codes
1211 ret=readcheatcodes(f, Header);
1212 break;
1213
1214 case ID_ITEMDROPSETS:
1215 //item drop sets
1216 // Why is this one commented out?
1217 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1218 break;
1219
1220 case ID_FAVORITES:
1221 // favorite combos and aliases
1222 ret=readfavorites(f, version, build);
1223 break;
1224
1225 default:
1226 ret=-1;
1227 break;
1228 }
1229
1230 pack_fclose(f);
1231 clear_quest_tmpfile();
1232
1233 if(deletefilename[0])
1234 {
1235 delete_file(deletefilename);
1236 }
1237
1238 //setPackfilePassword(NULL);
1239 if(!ret)
1240 {
1241 return true;
1242 }
1243
1244 return false;
1245 }
1246
1247 bool init_tiles(bool validate, zquestheader *Header)
1248 {
1249 return init_section(Header, ID_TILES, NULL, NULL, validate);
1250 }
1251
1252 bool init_combos(bool validate, zquestheader *Header)
1253 {
1254 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1255 }
1256
1257 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1258 {
1259 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1260 }
1261
1262 129 void init_spritelists()
1263 {
1264
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(FFCore.quest_format[vZelda] < 0x255)
1265 {
1266 93 guys.setMax(255);
1267 93 items.setMax(255);
1268 93 Ewpns.setMax(255);
1269 93 Lwpns.setMax(255);
1270 93 Sitems.setMax(255);
1271 93 chainlinks.setMax(255);
1272 93 decorations.setMax(255);
1273 93 particles.setMax(255);
1274 93 }
1275 else
1276 {
1277 36 guys.setMax(255);
1278 36 items.setMax(255);
1279 36 Ewpns.setMax(255);
1280 36 Lwpns.setMax(255);
1281 36 Sitems.setMax(255);
1282 36 chainlinks.setMax(255);
1283 36 decorations.setMax(255);
1284 36 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1285 }
1286 129 }
1287
1288 116 bool reset_items(bool validate, zquestheader *Header)
1289 {
1290 116 bool ret = true;
1291
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (get_app_id() == App::zquest)
1292 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1293
1294
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29696 times.
29812 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1295
1296 116 return ret;
1297 }
1298
1299 bool reset_guys()
1300 {
1301 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1302 init_guys(V_GUYS);
1303 return true;
1304 }
1305
1306 bool reset_wpns(bool validate, zquestheader *Header)
1307 {
1308 bool ret = true;
1309 if (get_app_id() == App::zquest)
1310 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1311
1312 for(int32_t i=0; i<MAXWPNS; i++)
1313 reset_weaponname(i);
1314
1315 return ret;
1316 }
1317
1318 bool reset_mapstyles(bool validate, miscQdata *Misc)
1319 {
1320 Misc->colors.blueframe_tile = 20044;
1321 Misc->colors.blueframe_cset = 0;
1322 Misc->colors.triforce_tile = 23461;
1323 Misc->colors.triforce_cset = 1;
1324 Misc->colors.triframe_tile = 18752;
1325 Misc->colors.triframe_cset = 1;
1326 Misc->colors.overworld_map_tile = 16990;
1327 Misc->colors.overworld_map_cset = 2;
1328 Misc->colors.HCpieces_tile = 21160;
1329 Misc->colors.HCpieces_cset = 8;
1330 Misc->colors.dungeon_map_tile = 19651;
1331 Misc->colors.dungeon_map_cset = 8;
1332 return true;
1333 }
1334
1335 116 int32_t get_qst_buffers()
1336 {
1337 116 memrequested+=(sizeof(mapscr)*MAPSCRS);
1338 116 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1339 116 TheMaps.resize(MAPSCRS);
1340 116 map_autolayers.resize(6);
1341
1342
2/2
✓ Branch 0 taken 15776 times.
✓ Branch 1 taken 116 times.
15892 for(int32_t i(0); i<MAPSCRS; i++)
1343 15776 TheMaps[i].zero_memory();
1344
1345 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1346 116 Z_message("OK\n"); // Allocating map buffer...
1347
1348 116 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1349 116 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1350
1351
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1352 return 0;
1353
1354 116 Z_message("OK\n");
1355
1356 // Allocating space for all 65535 strings uses up 10.62MB...
1357 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1358 // (Shoelace's "Hero of Dreams" uses 1415.)
1359 // So let's be a bit generous and allow 4096 initially.
1360 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1361 // I tested it and it worked without flaw on 6/6/11. - L.
1362 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1363 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1364 // See https://discord.com/channels/876899628556091432/992984989073416242
1365 116 msg_strings_size = 8192;
1366 116 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1367 116 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1368
1369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 MsgStrings = new MsgStr[msg_strings_size];
1370
1371 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1372
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 116 times.
950388 for(auto q = 0; q < msg_strings_size; ++q)
1373 {
1374 950272 MsgStrings[q].clear();
1375 950272 }
1376 116 Z_message("OK\n"); // Allocating string buffer...
1377
1378 116 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1379 116 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1380
1381
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1382 return 0;
1383
1384 116 Z_message("OK\n"); // Allocating door combo buffer...
1385
1386 116 memrequested+=(sizeof(dmap)*MAXDMAPS);
1387 116 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1388
1389
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1390 return 0;
1391
1392 116 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1393 116 Z_message("OK\n"); // Allocating dmap buffer...
1394
1395 116 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1396 116 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1397
1398 116 combobuf.clear();
1399 116 combobuf.resize(MAXCOMBOS);
1400 116 Z_message("OK\n"); // Allocating combo buffer...
1401
1402 116 memrequested+=(psTOTAL255);
1403 116 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1404
1405
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1406 return 0;
1407
1408 116 Z_message("OK\n"); // Allocating color data buffer...
1409
1410 116 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1411 116 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1412
1413 116 free_newtilebuf();
1414
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1415 return 0;
1416
1417 116 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1418 //Z_message("Performed memset on tiles\n");
1419 116 clear_tiles(newtilebuf);
1420 //Z_message("Performed clear_tiles()\n");
1421 116 Z_message("OK\n"); // Allocating tile buffer...
1422
1423
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(is_zquest())
1424 {
1425 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1426 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1427
1428 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1429 return 0;
1430
1431 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1432 clear_tiles(grabtilebuf);
1433 Z_message("OK\n"); // Allocating tile grab buffer...
1434 }
1435
1436 116 memrequested+=(100000);
1437 116 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1438
1439
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((trashbuf=(byte*)malloc(100000))==NULL)
1440 return 0;
1441
1442 116 Z_message("OK\n"); // Allocating trash buffer...
1443
1444 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1445 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1446 // fixed by ensuring there's actually itemdata there.
1447 // If you change this, be sure to update del_qst_buffers, too.
1448
1449 116 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1450 116 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1451
1452
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1453 return 0;
1454
1455 116 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1456 116 itemsbuf++;
1457 116 Z_message("OK\n"); // Allocating item buffer...
1458
1459 116 memrequested+=(sizeof(wpndata)*MAXWPNS);
1460 116 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1461
1462
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1463 return 0;
1464
1465 116 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1466 116 Z_message("OK\n"); // Allocating weapon buffer...
1467
1468 116 memrequested+=(sizeof(guydata)*MAXGUYS);
1469 116 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1470
1471
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1472 return 0;
1473
1474 116 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1475 116 Z_message("OK\n"); // Allocating guy buffer...
1476
1477 116 memrequested+=(sizeof(comboclass)*cMAX);
1478 116 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1479
1480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1481 return 0;
1482
1483 116 Z_message("OK\n"); // Allocating combo class buffer...
1484
1485 116 return 1;
1486 116 }
1487
1488
1489 116 void free_newtilebuf()
1490 {
1491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(newtilebuf)
1492 {
1493 for(int32_t i=0; i<NEWMAXTILES; i++)
1494 if(newtilebuf[i].data)
1495 free(newtilebuf[i].data);
1496
1497 free(newtilebuf);
1498 newtilebuf = 0;
1499 }
1500 116 }
1501
1502 void free_grabtilebuf()
1503 {
1504 if(is_zquest())
1505 {
1506 if(grabtilebuf)
1507 {
1508 for(int32_t i=0; i<NEWMAXTILES; i++)
1509 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1510
1511 free(grabtilebuf);
1512 grabtilebuf = 0;
1513 }
1514 }
1515 }
1516
1517 void del_qst_buffers()
1518 {
1519 al_trace("Cleaning maps. \n");
1520
1521 if(ZCMaps) free(ZCMaps);
1522
1523 if(MsgStrings) delete[] MsgStrings;
1524
1525 if(DoorComboSets) free(DoorComboSets);
1526
1527 if(DMaps) free(DMaps);
1528
1529 combobuf.clear();
1530
1531 if(colordata) free(colordata);
1532
1533 al_trace("Cleaning tile buffers. \n");
1534 free_newtilebuf();
1535 free_grabtilebuf();
1536
1537 al_trace("Cleaning misc. \n");
1538
1539 if(trashbuf) free(trashbuf);
1540
1541 // See get_qst_buffers
1542 if(itemsbuf)
1543 {
1544 itemsbuf--;
1545 free(itemsbuf);
1546 }
1547
1548 if(wpnsbuf) free(wpnsbuf);
1549
1550 if(guysbuf) free(guysbuf);
1551
1552 if(combo_class_buf) free(combo_class_buf);
1553 }
1554
1555 4 bool init_palnames()
1556 {
1557 // if(palnames==NULL)
1558 // return false;
1559
1560
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1561 {
1562
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1563 {
1564 case 0:
1565 4 sprintf(palnames[x],"Overworld");
1566 4 break;
1567
1568 case 10:
1569 4 sprintf(palnames[x],"Caves");
1570 4 break;
1571
1572 case 11:
1573 4 sprintf(palnames[x],"Passageways");
1574 4 break;
1575
1576 default:
1577 2036 sprintf(palnames[x],"%c",0);
1578 2036 break;
1579 }
1580 2048 }
1581
1582 4 return true;
1583 }
1584
1585 25210 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1586 {
1587 void *p;
1588
1589
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 p = _AL_MALLOC(MAX(size, alloc_size));
1590
1591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25210 times.
25210 if(!p)
1592 {
1593 return NULL;
1594 }
1595
1596
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(!pfread(p,size,f))
1597 {
1598 _AL_FREE(p);
1599 return NULL;
1600 }
1601
1602
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(pack_ferror(f))
1603 {
1604 _AL_FREE(p);
1605 return NULL;
1606 }
1607
1608 25210 return p;
1609 25210 }
1610
1611 /* read_midi:
1612 * Reads MIDI data from a datafile (this is not the same thing as the
1613 * standard midi file format).
1614 */
1615
1616 2302 static MIDI *read_midi(PACKFILE *f)
1617 {
1618 MIDI *m;
1619 int32_t c;
1620 2302 int16_t divisions=0;
1621 2302 int32_t len=0;
1622
1623 2302 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1624
1625
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!m)
1626 {
1627 return NULL;
1628 }
1629
1630
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1631 {
1632 73664 m->track[c].len = 0;
1633 73664 m->track[c].data = NULL;
1634 73664 }
1635
1636 2302 p_mgetw(&divisions,f);
1637 2302 m->divisions=divisions;
1638
1639
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1640 {
1641 73664 p_mgetl(&len,f);
1642 73664 m->track[c].len=len;
1643
1644
2/2
✓ Branch 0 taken 48454 times.
✓ Branch 1 taken 25210 times.
73664 if(m->track[c].len > 0)
1645 {
1646 25210 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1647
1648
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(!m->track[c].data)
1649 {
1650 destroy_midi(m);
1651 return NULL;
1652 }
1653 25210 }
1654 73664 }
1655
1656 LOCK_DATA(m, sizeof(MIDI));
1657
1658
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1659 {
1660
2/2
✓ Branch 0 taken 25210 times.
✓ Branch 1 taken 48454 times.
73664 if(m->track[c].data)
1661 {
1662 LOCK_DATA(m->track[c].data, m->track[c].len);
1663 25210 }
1664 73664 }
1665
1666 2302 return m;
1667 2302 }
1668
1669 void clear_combo(int32_t i)
1670 {
1671 combobuf[i].clear();
1672 }
1673
1674 void clear_combos()
1675 {
1676 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1677 clear_combo(tmpcounter);
1678 }
1679
1680 void pack_combos()
1681 {
1682 int32_t di = 0;
1683
1684 for(int32_t si=0; si<1024; si+=2)
1685 combobuf[di++] = combobuf[si];
1686
1687 for(; di<1024; di++)
1688 clear_combo(di);
1689 }
1690
1691 129 void reset_tunes(zctune *tune)
1692 {
1693
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1694 {
1695 32508 tune[i].reset();
1696 32508 }
1697 129 }
1698
1699
1700 /*void reset_midi(zcmidi_ *m)
1701 {
1702 m->title[0]=0;
1703 m->loop=1;
1704 m->volume=144;
1705 m->start=0;
1706 m->loop_start=-1;
1707 m->loop_end=-1;
1708 if(m->midi)
1709 {
1710 destroy_midi(m->midi);
1711 }
1712 m->midi=NULL;
1713 }
1714
1715
1716 void reset_midis(zcmidi_ *m)
1717 {
1718 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1719 {
1720 reset_midi(m+i);
1721 }
1722 }
1723 */
1724
1725 void reset_scr(int32_t scr)
1726 {
1727 /*
1728 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1729 for(unsigned i=0; i<sizeof(mapscr); i++)
1730 *(di++) = 0;
1731 TheMaps[scr].valid=mVERSION;
1732 */
1733
1734 TheMaps[scr].zero_memory();
1735 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1736
1737 for(int32_t i=0; i<6; i++)
1738 {
1739 //these will be uncommented later
1740 //TheMaps[scr].layerxsize[i]=16;
1741 //TheMaps[scr].layerysize[i]=11;
1742 TheMaps[scr].layeropacity[i]=255;
1743 }
1744
1745 TheMaps[scr].valid=mVERSION;
1746
1747 }
1748
1749 /* For reference:
1750
1751 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1752 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1753 */
1754
1755 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1756 {
1757
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1758 {
1759
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1760 {
1761
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1762 {
1763
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1764 {
1765 1968 return false;
1766 }
1767
1768
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1769 {
1770 return false;
1771 }
1772
1773
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1774 {
1775 return false;
1776 }
1777
1778
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1779 {
1780 return false;
1781 }
1782 57816 }
1783
1784
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1785 {
1786 return false;
1787 }
1788
1789
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1790 {
1791 return false;
1792 }
1793
1794
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1795 {
1796 return false;
1797 }
1798
1799
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1800 {
1801 return false;
1802 }
1803 86724 }
1804
1805
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1806 {
1807
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1808 {
1809 return false;
1810 }
1811
1812
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1813 {
1814 return false;
1815 }
1816
1817
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1818 {
1819 return false;
1820 }
1821
1822
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1823 {
1824 return false;
1825 }
1826
1827
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1828 {
1829 return false;
1830 }
1831 3212 }
1832
1833
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1834 {
1835
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1836 {
1837 return false;
1838 }
1839
1840
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1841 {
1842 return false;
1843 }
1844
1845
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1846 {
1847 return false;
1848 }
1849
1850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1851 {
1852 return false;
1853 }
1854 4818 }
1855
1856
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1857 {
1858 return false;
1859 }
1860
1861
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1862 {
1863 return false;
1864 }
1865 14454 }
1866
1867 1606 return true;
1868 3574 }
1869
1870 int32_t doortranslations_u[9][4]=
1871 {
1872 {37,38,53,54},
1873 {37,38,39,40},
1874 {37,38,55,56},
1875 {37,38,39,40},
1876 {37,38,53,54},
1877 {37,38,53,54},
1878 {37,38,53,54},
1879 {7,8,23,24},
1880 {7,8,41,42}
1881 };
1882
1883 int32_t doortranslations_d[9][4]=
1884 {
1885 {117,118,133,134},
1886 {135,136,133,134},
1887 {119,120,133,134},
1888 {135,136,133,134},
1889 {117,118,133,134},
1890 {117,118,133,134},
1891 {117,118,133,134},
1892 {151,152,167,168},
1893 {137,138,167,168},
1894 };
1895
1896 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1897 int32_t doortranslations_l[9][6]=
1898 {
1899 {66,67,82,83,98,99},
1900 {66,68,82,84,98,100},
1901 {66,69,82,85,98,101},
1902 {66,68,82,84,98,100},
1903 {66,67,82,83,98,99},
1904 {66,67,82,83,98,99},
1905 {66,67,82,83,98,99},
1906 {64,65,80,81,96,97},
1907 {64,65,80,114,96,97},
1908 };
1909
1910 int32_t doortranslations_r[9][6]=
1911 {
1912
1913 {76,77,92,93,108,109},
1914 {75,77,91,93,107,109},
1915 {74,77,90,93,106,109},
1916 {75,77,91,93,107,109},
1917 {76,77,92,93,108,109},
1918 {76,77,92,93,108,109},
1919 {76,77,92,93,108,109},
1920 {78,79,94,95,110,111},
1921 {78,79,125,95,110,111},
1922 };
1923
1924 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1925 {
1926 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1927 }
1928
1929 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1930 {
1931 //these are here to bypass compiler warnings about unused arguments
1932 308180 map=map;
1933 308180 scr=scr;
1934 308180 pos=pos;
1935
1936 //what does this function do?
1937 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1938 308180 return 2;
1939 }
1940
1941 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1942 {
1943
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1944 {
1945 5450 return 0;
1946 }
1947
1948 DoorComboSet tempdcs;
1949 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1950
1951 //up
1952
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1953 {
1954
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1955 {
1956 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1957 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1958 58392 }
1959 14598 }
1960
1961 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1962 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1963 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1964 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1965 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1966 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1967
1968 //down
1969
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1970 {
1971
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1972 {
1973 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1974 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1975 58392 }
1976 14598 }
1977
1978 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1979
1980 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1981 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1982 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1983 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1984 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1985
1986 //left
1987 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1988
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1989 {
1990
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1991 {
1992 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1993 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1994 87588 }
1995 14598 }
1996
1997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1998 {
1999 if((j!=2)&&(j!=3))
2000 {
2001 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
2002 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
2003 }
2004 }
2005
2006 1622 tempdcs.bombdoorcombo_l[0]=0;
2007 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2008 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2009 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2010 1622 tempdcs.bombdoorcombo_l[2]=0;
2011 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2012 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2013 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2014
2015 //right
2016
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2017 {
2018
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2019 {
2020 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2021 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2022 87588 }
2023 14598 }
2024
2025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2026 {
2027 if((j!=2)&&(j!=3))
2028 {
2029 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2030 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2031 }
2032 }
2033
2034 1622 tempdcs.bombdoorcombo_r[0]=0;
2035 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2036 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2037 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2038 1622 tempdcs.bombdoorcombo_r[2]=0;
2039 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2040 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2041 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2042
2043 int32_t k;
2044
2045
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
2046 {
2047
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
2048 {
2049 1606 break;
2050 }
2051 1968 }
2052
2053
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
2054 {
2055 16 DoorComboSets[k]=tempdcs;
2056 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2057 16 ++door_combo_set_count;
2058 16 }
2059
2060 1622 return k;
2061 /*
2062 doorcombo_u[9][4];
2063 doorcset_u[9][4];
2064 doorcombo_d[9][4];
2065 doorcset_d[9][4];
2066 doorcombo_l[9][6];
2067 doorcset_l[9][6];
2068 doorcombo_r[9][6];
2069 doorcset_r[9][6];
2070 bombdoorcombo_u[2];
2071 bombdoorcset_u[2];
2072 bombdoorcombo_d[2];
2073 bombdoorcset_d[2];
2074 bombdoorcombo_l[3];
2075 bombdoorcset_l[3];
2076 bombdoorcombo_r[3];
2077 bombdoorcset_r[3];
2078 walkthroughcombo[4];
2079 walkthroughcset[4];
2080 */
2081 7072 }
2082
2083 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2084 {
2085 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2086 }
2087
2088 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2089 {
2090
2091 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2092 }
2093
2094 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2095 {
2096 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2097 }
2098
2099
2100 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2101 {
2102 char temp_pwd[30];
2103 16 memset(temp_pwd,0,30);
2104
2105
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
2106 {
2107 16 memcpy(temp_pwd,encrypted_pwd,30);
2108 16 temp_pwd[29]=0;
2109
2110
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
2111 {
2112 480 temp_pwd[i] -= pwdkey;
2113 480 int32_t t=pwdkey>>15;
2114 480 pwdkey = (pwdkey<<1)+t;
2115 480 }
2116 16 }
2117
2118 16 memcpy(pwd,temp_pwd,30);
2119 16 }
2120
2121
2122 92 bool devpwd()
2123 {
2124 92 return true; // TODO !!
2125 #ifdef _DEBUG
2126 return true;
2127 #endif
2128 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2129 }
2130 bool check_questpwd(zquestheader *Header, char *pwd)
2131 {
2132 #if DEVLEVEL > 3
2133 return true;
2134 #endif
2135
2136 if (devpwd()) return true;
2137 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2138 cvs_MD5Context ctx;
2139 uint8_t md5sum[16];
2140
2141 cvs_MD5Init(&ctx);
2142 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2143 cvs_MD5Final(md5sum, &ctx);
2144
2145 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2146 }
2147
2148 121 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2149 {
2150 121 zprint2("\n");
2151 121 zprint2("[ZQUEST CREATOR METADATA]\n");
2152
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(qst_num < moduledata.max_quest_files)
2153 zprint2("Loading module quest %d\n", qst_num+1);
2154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(path) zprint2("Loading '%s'\n", path);
2155
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 4 times.
121 if ( tempheader.new_version_id_main > 0 )
2156 {
2157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(tempheader.new_version_id_fourth > 0)
2158 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2159 tempheader.new_version_id_main,tempheader.new_version_id_second,
2160 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2161 117 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2162 117 tempheader.new_version_id_main,tempheader.new_version_id_second,
2163 117 tempheader.new_version_id_third);
2164 117 }
2165 else
2166 {
2167
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2168 {
2169 case 0x255:
2170 {
2171 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2172 break;
2173 }
2174 case 0x254:
2175 {
2176 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2177 break;
2178 }
2179 case 0x250:
2180 {
2181 switch(tempheader.build)
2182 {
2183 case 19:
2184 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2185 case 20:
2186 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2187 case 21:
2188 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2189 case 22:
2190 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2191 case 23:
2192 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2193 case 24:
2194 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2195 case 25:
2196 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2197 case 26:
2198 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2199 case 27:
2200 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2201 case 28:
2202 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2203 case 29:
2204 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2205 case 30:
2206 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2207 case 31:
2208 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2209 case 32:
2210 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2211 case 33:
2212 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2213 default:
2214 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2215
2216 }
2217 break;
2218 }
2219
2220 case 0x211:
2221 {
2222 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2223 }
2224 case 0x210:
2225 {
2226 zprint2("Last saved in ZQuest Version: 2.10.x");
2227 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2228 break;
2229 }
2230 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2231 case 0x193:
2232 {
2233 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2234 }
2235 case 0x192:
2236 {
2237 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2238 }
2239 case 0x190:
2240 {
2241 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2242 }
2243 case 0x184:
2244 {
2245 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2246 }
2247 case 0x183:
2248 {
2249 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2250 }
2251 case 0x180:
2252 {
2253 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2254 }
2255 default:
2256 {
2257 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2258 }
2259 */
2260 }
2261 }
2262
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
121 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2263 28 zprint2("%s\n", tempheader.getAlphaVerStr());
2264 93 else zprint2("\n");
2265
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2266
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2267
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2268
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 117 times.
121 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2270
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2271 121 zprint2("\n");
2272 121 }
2273
2274 129 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2275 {
2276 int32_t dummy;
2277 zquestheader tempheader;
2278 char dummybuf[80];
2279 byte temp_map_count;
2280 byte temp_midi_flags[MIDIFLAGS_SIZE];
2281 word version;
2282 char temp_pwd[30], temp_pwd2[30];
2283 int16_t temp_pwdkey;
2284 cvs_MD5Context ctx;
2285 129 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2286 129 memset(&tempheader, 0, sizeof(tempheader));
2287 129 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2288
2289
2290
2291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2292 {
2293 Z_message("Unable to read header string\n");
2294 return qe_invalid;
2295 }
2296
2297 // check header
2298
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2299 {
2300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2301 {
2302 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2303 return qe_invalid;
2304 }
2305 4 }
2306
2307 129 int32_t templatepath_len=0;
2308
2309 129 tempheader.external_zinfo = false;
2310 129 read_zinfo = false;
2311
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2312 {
2313 byte padding;
2314
2315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2316 {
2317 return qe_invalid;
2318 }
2319
2320
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2321 {
2322 return qe_invalid;
2323 }
2324
2325 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2326
2327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2328 {
2329 return qe_version;
2330 }
2331
2332 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2333
2334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2335 {
2336 return qe_invalid;
2337 }
2338
2339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2340 {
2341 return qe_obsolete;
2342 }
2343
2344
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2345 {
2346 return qe_invalid;
2347 }
2348
2349
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2355
2356
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2357 {
2358 return qe_invalid;
2359 }
2360
2361
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2362 {
2363 return qe_invalid;
2364 }
2365
2366 4 FFCore.quest_format[qMapCount] = temp_map_count;
2367
2368
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2374 {
2375 return qe_invalid;
2376 }
2377
2378
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2383
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2384 {
2385 return qe_invalid;
2386 }
2387
2388
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2389 {
2390 return qe_invalid;
2391 }
2392
2393
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2398
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2399 {
2400 return qe_invalid;
2401 }
2402
2403
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2408
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2409 {
2410 return qe_invalid;
2411 }
2412 // These fields are expected to end in null bytes!
2413 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2414
2415
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2416 {
2417 return qe_invalid;
2418 }
2419 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2420
2421
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2422 {
2423 return qe_invalid;
2424 }
2425
2426
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2427 {
2428 return qe_invalid;
2429 }
2430
2431
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2436 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2437 4 cvs_MD5Init(&ctx);
2438 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2439 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2440
2441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2442 {
2443 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2444 // Not anymore...
2445 memset(tempheader.minver,0,17);
2446 tempheader.build=0;
2447 tempheader.use_keyfile=0;
2448 memset(tempheader.old_foo, 0, 9);
2449 }
2450 else
2451 {
2452
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2453 {
2454 return qe_invalid;
2455 }
2456
2457
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2458 {
2459 return qe_invalid;
2460 }
2461
2462 4 FFCore.quest_format[vBuild] = tempheader.build;
2463
2464
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2465 {
2466 return qe_invalid;
2467 }
2468
2469
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2470 {
2471 return qe_invalid;
2472 }
2473 } // starting at minver
2474
2475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2476 {
2477 memset(&quest_rules[4],0,16); // word rules3..rules10
2478 }
2479 else
2480 {
2481
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2482 {
2483 return qe_invalid; // starting at rules3
2484 }
2485
2486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2487 {
2488 4 set_qr(qr_MEANPLACEDTRAPS,0);
2489 4 }
2490 }
2491
2492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2493 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2494 {
2495 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2496 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2497 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2498 4 }
2499
2500
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2501 {
2502 byte *mf=temp_midi_flags;
2503
2504 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2505 {
2506 mf=(byte*)dummybuf;
2507 }
2508
2509 if(!pfread(mf,32,f)) // read new header additions
2510 {
2511 return qe_invalid; // starting at foo2
2512 }
2513
2514 if(!pfread(dummybuf,18,f)) // read new header additions
2515 {
2516 return qe_invalid; // starting at foo2
2517 }
2518 }
2519
2520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2521 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2522 {
2523 4 memset(tempheader.templatepath,0,2048);
2524 4 }
2525 else
2526 {
2527 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2528 {
2529 return qe_invalid;
2530 }
2531 }
2532
2533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2534 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2535 {
2536 4 tempheader.use_keyfile=0;
2537 4 }
2538 4 }
2539 else
2540 {
2541 //section id
2542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_mgetl(&dummy,f))
2543 {
2544 return qe_invalid;
2545 }
2546
2547 //section version info
2548
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
2549 {
2550 return qe_invalid;
2551 }
2552
2553 125 FFCore.quest_format[vHeader] = version;
2554
2555
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
2556 {
2557 return qe_invalid;
2558 }
2559
2560 //section size
2561
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
2562 {
2563 return qe_invalid;
2564 }
2565
2566 //finally... section data
2567
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.zelda_version,f))
2568 {
2569 return qe_invalid;
2570 }
2571
2572 125 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2573
2574 //do some quick checking...
2575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(tempheader.zelda_version > ZELDA_VERSION)
2576 {
2577 return qe_version;
2578 }
2579
2580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2581 {
2582 return qe_invalid;
2583 }
2584
2585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(bad_version(tempheader.zelda_version))
2586 {
2587 return qe_obsolete;
2588 }
2589
2590
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.build,f))
2591 {
2592 return qe_invalid;
2593 }
2594
2595 125 FFCore.quest_format[vBuild] = tempheader.build;
2596
2597
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(version<3)
2598 {
2599
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2600 {
2601 return qe_invalid;
2602 }
2603
2604
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2605 {
2606 return qe_invalid;
2607 }
2608
2609 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2610 12 cvs_MD5Init(&ctx);
2611 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2612 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2613 12 }
2614 else
2615 {
2616
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2617 {
2618 return qe_invalid;
2619 }
2620 }
2621
2622
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.internal,f))
2623 {
2624 return qe_invalid;
2625 }
2626
2627
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.quest_number,f))
2628 {
2629 return qe_invalid;
2630 }
2631
2632 125 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2633
2634 125 size_t versz = version < 8 ? 9 : 16;
2635
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.version,versz,f))
2636 {
2637 return qe_invalid;
2638 }
2639
2640 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2641 //needs to be copied as char[9] or stored as a s.str
2642
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.minver,versz,f))
2643 {
2644 return qe_invalid;
2645 }
2646
2647 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2648
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2649 {
2650 return qe_invalid;
2651 }
2652 125 tempheader.title[sizeof(tempheader.title)-1] = 0;
2653
2654
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2655 {
2656 return qe_invalid;
2657 }
2658 125 tempheader.author[sizeof(tempheader.author)-1] = 0;
2659
2660
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.use_keyfile,f))
2661 {
2662 return qe_invalid;
2663 }
2664
2665 /*
2666 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2667 {
2668 return qe_invalid;
2669 }
2670 */
2671
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2672 {
2673 return qe_invalid;
2674 }
2675
2676
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(&dummybuf,4,f))
2677 {
2678 return qe_invalid;
2679 }
2680
2681
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2682 {
2683 return qe_invalid;
2684 }
2685
2686
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(dummybuf,14,f))
2687 {
2688 return qe_invalid;
2689 }
2690
2691 125 templatepath_len=sizeof(tempheader.templatepath);
2692
2693
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(version==1)
2694 {
2695 12 templatepath_len=280;
2696 12 }
2697
2698
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.templatepath,templatepath_len,f))
2699 {
2700 return qe_invalid;
2701 }
2702
2703
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&temp_map_count,f))
2704 {
2705 return qe_invalid;
2706 }
2707
2708
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version>=4)
2709 {
2710
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_main,f))
2711 {
2712 return qe_invalid;
2713 }
2714
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_second,f))
2715 {
2716 return qe_invalid;
2717 }
2718
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_third,f))
2719 {
2720 return qe_invalid;
2721 }
2722
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2723 {
2724 return qe_invalid;
2725 }
2726
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2727 {
2728 return qe_invalid;
2729 }
2730
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_beta,f))
2731 {
2732 return qe_invalid;
2733 }
2734
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2735 {
2736 return qe_invalid;
2737 }
2738
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_release,f))
2739 {
2740 return qe_invalid;
2741 }
2742
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2743 {
2744 return qe_invalid;
2745 }
2746
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_month,f))
2747 {
2748 return qe_invalid;
2749 }
2750
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_day,f))
2751 {
2752 return qe_invalid;
2753 }
2754
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2755 {
2756 return qe_invalid;
2757 }
2758
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2759 {
2760 return qe_invalid;
2761 }
2762
2763
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_devsig,256,f))
2764 {
2765 return qe_invalid;
2766 }
2767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2768 strcpy(tempheader.new_version_devsig, "EmilyV99");
2769
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilername,256,f))
2770 {
2771 return qe_invalid;
2772 }
2773
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilerversion,256,f))
2774 {
2775 return qe_invalid;
2776 }
2777
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.product_name,1024,f))
2778 {
2779 return qe_invalid;
2780 }
2781
2782
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.compilerid,f))
2783 {
2784 return qe_invalid;
2785 }
2786
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2787 {
2788 return qe_invalid;
2789 }
2790
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2791 {
2792 return qe_invalid;
2793 }
2794
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2795 {
2796 return qe_invalid;
2797 }
2798
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2799 {
2800 return qe_invalid;
2801 }
2802
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.developerid,f))
2803 {
2804 return qe_invalid;
2805 }
2806
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.made_in_module_name,1024,f))
2807 {
2808 return qe_invalid;
2809 }
2810
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_datestamp,256,f))
2811 {
2812 return qe_invalid;
2813 }
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(tempheader.build_timestamp,256,f))
2815 {
2816 return qe_invalid;
2817 }
2818 36 }
2819 else // <4
2820 {
2821 89 tempheader.new_version_id_main = 0;
2822 89 tempheader.new_version_id_second = 0;
2823 89 tempheader.new_version_id_third = 0;
2824 89 tempheader.new_version_id_fourth = 0;
2825 89 tempheader.new_version_id_alpha = 0;
2826 89 tempheader.new_version_id_beta = 0;
2827 89 tempheader.new_version_id_gamma = 0;
2828 89 tempheader.new_version_id_release = 0;
2829 89 tempheader.new_version_id_date_year = 0;
2830 89 tempheader.new_version_id_date_month = 0;
2831 89 tempheader.new_version_id_date_day = 0;
2832 89 tempheader.new_version_id_date_hour = 0;
2833 89 tempheader.new_version_id_date_minute = 0;
2834
2835 89 memset(tempheader.new_version_devsig, 0, 256);
2836 89 memset(tempheader.new_version_compilername, 0, 256);
2837 89 memset(tempheader.new_version_compilerversion, 0, 256);
2838 89 memset(tempheader.product_name, 0, 1024);
2839 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2840
2841 89 tempheader.compilerid = 0;
2842 89 tempheader.compilerversionnumber_first = 0;
2843 89 tempheader.compilerversionnumber_second = 0;
2844 89 tempheader.compilerversionnumber_third = 0;
2845 89 tempheader.compilerversionnumber_fourth = 0;
2846 89 tempheader.developerid = 0;
2847
2848 89 memset(tempheader.made_in_module_name, 0, 1024);
2849 89 memset(tempheader.build_datestamp, 0, 256);
2850 89 memset(tempheader.build_timestamp, 0, 256);
2851 }
2852
2853
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( version >= 5 )
2854 {
2855
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_timezone,6,f))
2856 {
2857 return qe_invalid;
2858 }
2859 36 }
2860 else // < 5
2861 {
2862 89 memset(tempheader.build_timezone, 0, 6);
2863 }
2864
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( version >= 6 )
2865 {
2866 byte b;
2867
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&b,f))
2868 {
2869 return qe_invalid;
2870 }
2871 36 tempheader.external_zinfo = b?true:false;
2872 36 read_zinfo = true;
2873 36 }
2874
2875
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version >= 7)
2876 {
2877
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2878 {
2879 return qe_invalid;
2880 }
2881 36 }
2882 else
2883 {
2884 89 tempheader.new_version_is_nightly = false;
2885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2886 {
2887
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2888 {
2889 case 0x254:
2890 tempheader.new_version_id_main = 2;
2891 tempheader.new_version_id_second = 54;
2892 break;
2893 case 0x250:
2894
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2895 {
2896 case 19:
2897 tempheader.new_version_id_main = 2;
2898 tempheader.new_version_id_second = 50;
2899 tempheader.new_version_id_gamma = 1;
2900 break;
2901 case 20:
2902 tempheader.new_version_id_main = 2;
2903 tempheader.new_version_id_second = 50;
2904 tempheader.new_version_id_gamma = 2;
2905 break;
2906 case 21:
2907 tempheader.new_version_id_main = 2;
2908 tempheader.new_version_id_second = 50;
2909 tempheader.new_version_id_gamma = 3;
2910 break;
2911 case 22:
2912 tempheader.new_version_id_main = 2;
2913 tempheader.new_version_id_second = 50;
2914 tempheader.new_version_id_gamma = 4;
2915 break;
2916 case 23:
2917 tempheader.new_version_id_main = 2;
2918 tempheader.new_version_id_second = 50;
2919 tempheader.new_version_id_gamma = 5;
2920 break;
2921 case 24:
2922 22 tempheader.new_version_id_main = 2;
2923 22 tempheader.new_version_id_second = 50;
2924 22 tempheader.new_version_id_release = -1;
2925 22 break;
2926 case 25:
2927 tempheader.new_version_id_main = 2;
2928 tempheader.new_version_id_second = 50;
2929 tempheader.new_version_id_third = 1;
2930 tempheader.new_version_id_gamma = 1;
2931 break;
2932 case 26:
2933 tempheader.new_version_id_main = 2;
2934 tempheader.new_version_id_second = 50;
2935 tempheader.new_version_id_third = 1;
2936 tempheader.new_version_id_gamma = 2;
2937 break;
2938 case 27:
2939 tempheader.new_version_id_main = 2;
2940 tempheader.new_version_id_second = 50;
2941 tempheader.new_version_id_third = 1;
2942 tempheader.new_version_id_gamma = 3;
2943 break;
2944 case 28:
2945 5 tempheader.new_version_id_main = 2;
2946 5 tempheader.new_version_id_second = 50;
2947 5 tempheader.new_version_id_third = 1;
2948 5 tempheader.new_version_id_release = -1;
2949 5 break;
2950 case 29:
2951 24 tempheader.new_version_id_main = 2;
2952 24 tempheader.new_version_id_second = 50;
2953 24 tempheader.new_version_id_third = 2;
2954 24 tempheader.new_version_id_release = -1;
2955 24 break;
2956 case 30:
2957 tempheader.new_version_id_main = 2;
2958 tempheader.new_version_id_second = 50;
2959 tempheader.new_version_id_third = 3;
2960 tempheader.new_version_id_gamma = 1;
2961 break;
2962 case 31:
2963 15 tempheader.new_version_id_main = 2;
2964 15 tempheader.new_version_id_second = 53;
2965 15 tempheader.new_version_id_gamma = -1;
2966 15 break;
2967 case 32:
2968 10 tempheader.new_version_id_main = 2;
2969 10 tempheader.new_version_id_second = 53;
2970 10 tempheader.new_version_id_release = -1;
2971 10 break;
2972 case 33:
2973 1 tempheader.new_version_id_main = 2;
2974 1 tempheader.new_version_id_second = 53;
2975 1 tempheader.new_version_id_third = 1;
2976 1 break;
2977 }
2978 77 break;
2979
2980 case 0x211:
2981 tempheader.new_version_id_main = 2;
2982 tempheader.new_version_id_second = 11;
2983 tempheader.new_version_id_beta = tempheader.build;
2984 break;
2985 case 0x210:
2986 12 tempheader.new_version_id_main = 2;
2987 12 tempheader.new_version_id_second = 10;
2988 12 tempheader.new_version_id_beta = tempheader.build;
2989 12 break;
2990 }
2991 89 }
2992 }
2993
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(printmetadata || __isZQuest)
2994 {
2995 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2996 }
2997 }
2998
2999 //{ Version Warning
3000 129 int32_t vercmp = tempheader.compareVer();
3001 129 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
3002 129 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
3003
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
165 if(vercmp > 0 || (!vercmp &&
3004
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 (astatecmp > 0 || (!astatecmp &&
3005 36 avercmp > 0))))
3006 {
3007 bool r = true;
3008 if(loadquest_report)
3009 {
3010 enter_sys_pal();
3011 AlertDialog("Quest saved in newer version",
3012 "This quest was last saved in a newer version of ZQuest."
3013 " Attempting to load this quest may not work correctly; to"
3014 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3015 "\n\nWould you like to continue loading anyway? (Not recommended)",
3016 [&](bool ret,bool)
3017 {
3018 r = ret;
3019 }).show();
3020 exit_sys_pal();
3021 }
3022 if(!r)
3023 return qe_silenterr;
3024 }
3025
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 else if(tempheader.compareDate() > 0)
3026 {
3027 bool r = true;
3028 if(loadquest_report)
3029 {
3030 enter_sys_pal();
3031 AlertDialog("Quest saved in newer build",
3032 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3033 " issues loading in this build."
3034 "\n{}"
3035 "\n\nWould you like to continue loading anyway?",
3036 tempheader.getVerCmpStr()),
3037 [&](bool ret,bool)
3038 {
3039 r = ret;
3040 }).show();
3041 exit_sys_pal();
3042 }
3043 if(!r)
3044 return qe_silenterr;
3045 }
3046 //}
3047
3048 129 read_ext_zinfo = tempheader.external_zinfo;
3049
3050 129 memcpy(Header, &tempheader, sizeof(tempheader));
3051 129 map_count=temp_map_count;
3052 129 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3053
3054 129 return 0;
3055 129 }
3056
3057 129 int32_t readrules(PACKFILE *f, zquestheader *Header)
3058 {
3059 int32_t dummy;
3060 zquestheader tempheader;
3061 129 word s_version=0;
3062 129 dword compatrule_version=0;
3063
3064 129 memcpy(&tempheader, Header, sizeof(tempheader));
3065
3066
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(tempheader.zelda_version >= 0x193)
3067 {
3068 //section version info
3069
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
3070 {
3071 return qe_invalid;
3072 }
3073
3074 125 FFCore.quest_format[vRules] = s_version;
3075
3076
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
3077 {
3078 return qe_invalid;
3079 }
3080
3081
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version > 16)
3082 {
3083
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&compatrule_version,f))
3084 {
3085 return qe_invalid;
3086 }
3087 36 }
3088 125 FFCore.quest_format[vCompatRule] = compatrule_version;
3089
3090 //section size
3091
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
3092 {
3093 return qe_invalid;
3094 }
3095
3096
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( s_version < 15 )
3097 {
3098 //finally... section data
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
3100 {
3101 return qe_invalid;
3102 }
3103 89 }
3104 else
3105 {
3106
3107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
3108 {
3109 return qe_invalid;
3110 }
3111
3112 }
3113 125 }
3114
3115 //al_trace("Rules version %d\n", s_version);
3116 //{ bunch of compat stuff
3117 129 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3118
3119
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<2)
3120 {
3121 16 set_qr(14,0);
3122 16 set_qr(27,0);
3123 16 set_qr(28,0);
3124 16 set_qr(29,0);
3125 16 set_qr(30,0);
3126 16 set_qr(32,0);
3127 16 set_qr(36,0);
3128 16 set_qr(49,0);
3129 16 set_qr(50,0);
3130 16 set_qr(51,0);
3131 16 set_qr(68,0);
3132 16 set_qr(75,0);
3133 16 set_qr(76,0);
3134 16 set_qr(98,0);
3135 16 set_qr(110,0);
3136 16 set_qr(113,0);
3137 16 set_qr(116,0);
3138 16 set_qr(102,0);
3139 16 set_qr(132,0);
3140 16 }
3141
3142 //Now, do any updates...
3143
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3144 {
3145 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3146 16 set_qr(qr_REPLACEOPENDOORS, 1);
3147 16 set_qr(qr_OLDLENSORDER, 1);
3148 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3149 16 set_qr(qr_TRIGGERSREPEAT, 1);
3150 16 }
3151
3152
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3153 {
3154 4 set_qr(qr_WALLFLIERS,1);
3155 4 }
3156
3157
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3158 {
3159 4 set_qr(qr_NOBOMBPALFLASH,1);
3160 4 }
3161
3162
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
129 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3163 {
3164 6 set_qr(qr_NOSCROLLCONTINUE,1);
3165 6 }
3166
3167
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version <= 0x210)
3168 {
3169 16 set_qr(qr_ARROWCLIP,1);
3170 16 }
3171
3172
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 12 times.
127 if(tempheader.zelda_version == 0x210)
3173 {
3174 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3175 12 set_qr(qr_CMBCYCLELAYERS, 0);
3176 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3177 12 }
3178
3179
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
127 if(tempheader.zelda_version <= 0x210)
3180 {
3181 16 set_qr(qr_OLDSTYLEWARP,1);
3182 16 set_qr(qr_210_WARPRETURN,1);
3183 16 }
3184
3185 //might not be correct
3186
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 4 times.
127 if(tempheader.zelda_version < 0x210)
3187 {
3188 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3189 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3190 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3191 4 }
3192
3193
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
127 if(tempheader.zelda_version < 0x211)
3194 {
3195 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3196 16 }
3197
3198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
127 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3199 {
3200 set_qr(qr_192b163_WARP,1);
3201 }
3202
3203
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 12 times.
127 if(tempheader.zelda_version == 0x210)
3204 {
3205 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3206 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3207 12 set_qr(qr_DMGCOMBOPRI, 0);
3208 12 }
3209
3210
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
127 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3211 {
3212 16 set_qr(qr_OLDPICKUP,1);
3213 16 }
3214
3215
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3216 {
3217 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3218 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3219 16 }
3220
3221
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3222 {
3223 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3224 16 }
3225
3226
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
127 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3227 {
3228 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3229 22 }
3230
3231
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
127 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3232 {
3233 16 set_qr(qr_OLD_DOORREPAIR, 1);
3234 16 }
3235
3236
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
127 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3237 {
3238 16 set_qr(qr_OLD_SECRETMONEY, 1);
3239 16 }
3240
3241
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3242 {
3243 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3244 38 }
3245
3246
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3247 {
3248 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3249 38 }
3250
3251 //Bombchu fix.
3252
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 77 times.
131 if(tempheader.zelda_version == 0x250)
3253 {
3254
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3255 {
3256 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3257 22 }
3258
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3259 {
3260 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3261 5 }
3262
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3263 {
3264 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3265 24 }
3266
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3267 {
3268 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3269 }
3270 77 }
3271
3272
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3273 {
3274 // qr_OFFSETEWPNCOLLISIONFIX
3275 // All 'official' quests need this disabled.
3276 // All 2.10 and lower quests need this enabled to preseve compatability.
3277 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3278
3279 //~Gleeok
3280 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3281
3282 // Broke in build 695
3283
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3284 27 set_qr(qr_BROKENSTATUES, 1);
3285 43 }
3286
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if (tempheader.zelda_version <= 0x190)
3287 {
3288 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3289 4 }
3290
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 36 times.
131 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3291 {
3292 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3293 94 }
3294
3295
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3296 {
3297 16 set_qr(qr_OLD_210_WATER, 1);
3298 16 }
3299
3300
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3301 {
3302 93 set_qr(qr_STEP_IS_FLOAT,0);
3303 93 }
3304
3305
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( tempheader.zelda_version < 0x250 )
3306 {
3307 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3308 16 }
3309
3310
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 3)
3311 {
3312 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3313 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3314 16 }
3315
3316
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<4)
3317 {
3318 16 set_qr(10,0);
3319 16 }
3320
3321
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
3322 {
3323 16 set_qr(27,0);
3324 16 }
3325
3326
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<6)
3327 {
3328 16 set_qr(46,0);
3329 16 }
3330
3331
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<7) // January 2008
3332 {
3333 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3334 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3335 16 }
3336
3337
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version<8)
3338 {
3339 16 set_qr(12, 0);
3340 16 }
3341 else
3342 {
3343 113 set_bit(deprecated_rules, 12, 0);
3344 }
3345
3346
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<9) // October 2008
3347 {
3348 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3349 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3350 16 set_qr(qr_GHINI2BLINK_DEP,0);
3351 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3352 16 }
3353
3354
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<10) // December 2008
3355 {
3356 16 set_qr(qr_NOCLOCKS_DEP,0);
3357 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3358 16 }
3359
3360
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<11) // April 2009
3361 {
3362 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3363 16 }
3364
3365 // This served no purpose.
3366 // if(s_version<12) // December 2009
3367 // {
3368 // set_qr(qr_BRKBLSHLDS_DEP,0);
3369 // set_qr(qr_OLDTRIBBLES_DEP,0);
3370 // }
3371
3372 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3373
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 13)
3374 {
3375 16 set_qr(qr_SHOPCHEAT, 1);
3376 16 }
3377
3378 // Not entirely sure this is the best place for this...
3379 //2.50.2 bitmap offset fix
3380 129 memset(extra_rules, 0, EXTRARULES_SIZE);
3381
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3382 {
3383 43 set_er(er_BITMAPOFFSET, 1);
3384 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3385 43 }
3386 //required because quest templates also used this bit, although
3387 //it never did anything, before. -Z
3388
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 77 times.
129 if ( tempheader.zelda_version == 0x250 )
3389 {
3390
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3391 {
3392 39 set_er(er_BITMAPOFFSET, 0);
3393 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3394 39 }
3395 77 }
3396
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( tempheader.zelda_version == 0x254 )
3397 {
3398 set_er(er_BITMAPOFFSET, 0);
3399 set_qr(qr_BITMAPOFFSETFIX, 0);
3400 }
3401
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
129 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3402 {
3403 set_er(er_BITMAPOFFSET, 0);
3404 set_qr(qr_BITMAPOFFSETFIX, 0);
3405 }
3406 //optimise fast drawing for older versions.
3407
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3408 {
3409 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3410 93 }
3411 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3412 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3413 //older quests can set the rule by hand. We need a new qst.dat again.
3414
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3415 {
3416 set_qr(qr_OLDEWPNPARENT, 1);
3417 }
3418
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3419 {
3420 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3421 }
3422
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3423 {
3424 set_qr(qr_OLDQUESTMISC, 1);
3425 }
3426
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3427 {
3428 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3429 93 set_qr(qr_OLDEWPNPARENT, 0);
3430 93 set_qr(qr_OLDQUESTMISC, 0);
3431 93 }
3432
3433 //item scripts continue to run
3434
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3435 {
3436 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3437 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3438 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3439 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3440 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3441 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3442 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3443 93 }
3444
3445
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3446 {
3447 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3448 93 }
3449
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3450 {
3451 93 set_qr(qr_TRACESCRIPTIDS, 0);
3452 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3453 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3454 93 set_qr(qr_PARSER_250DIVISION,1);
3455 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3456 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3457 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3458 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3459
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3460 {
3461 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3462 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3463 //Now they **do**, unless you disable that behaviour.
3464 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3465 //now enable the disable L/R item swap on load.
3466 2 }
3467
3468 93 }
3469
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3470 {
3471 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3472 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3473 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3474 //animations ending earlier than they should.
3475 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3476 //Enemies would ignore solidity on the top half of combos
3477 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3478 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3479 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3480 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3481 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3482 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3483 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3484 93 }
3485
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x255 )
3486 {
3487 93 set_qr(qr_NOFFCWAITDRAW, 1);
3488 93 set_qr(qr_NOITEMWAITDRAW, 1);
3489 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3490 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3491 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3492 93 }
3493
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3494 {
3495 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3496 93 }
3497
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3498 {
3499 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3500 93 }
3501
3502
3503
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3504 {
3505 93 set_qr(qr_BROKEN_RING_POWER, 1);
3506 93 }
3507
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3508 {
3509 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3510 93 }
3511
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3512 {
3513 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3514 93 }
3515
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3516 {
3517 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3518
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3519 set_qr(qr_SET_YBUTTON_ITEMS,1);
3520 93 }
3521
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3522 {
3523 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3524 93 }
3525
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3526 {
3527 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3528 93 }
3529
3530
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3531 {
3532 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3533 93 }
3534 //Sideview spikes in 2.50.0
3535
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3536 {
3537 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3538 38 }
3539 //more 2.50 fixes -Z
3540
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3541 {
3542 67 set_qr(qr_MELEEMAGICCOST, 0);
3543 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3544 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3545 67 set_qr(qr_BROKENBOOKCOST, 1);
3546 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3547
3548 67 }
3549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3550 {
3551 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3552 set_qr(qr_MELEEMAGICCOST, 1);
3553 }
3554
3555
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version < 0x193)
3556 {
3557 4 set_qr(qr_SHORTDGNWALK, 1);
3558 4 }
3559
3560
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(tempheader.zelda_version < 0x255)
3561 {
3562 93 set_qr(qr_OLDINFMAGIC, 1);
3563 93 }
3564
3565
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3566 {
3567 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3568 16 }
3569
3570
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3571 {
3572 93 set_qr(qr_OLD_F6,1);
3573 93 }
3574
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3575 {
3576 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3577 93 }
3578
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3579 {
3580 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3581 93 }
3582
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3583 {
3584 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3585 93 }
3586 //}
3587
3588
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3589 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3590
3591
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 2) //Old CSet2 Handling
3592 93 set_qr(qr_OLDCS2,1);
3593
3594
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3595 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3596
3597
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3598 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3599
3600
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
129 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3601 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3602
3603
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3604 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3605
3606
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3607 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3608
3609
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3610 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3611
3612
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 9)
3613 {
3614 //Hardcoded BS Patras
3615 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3616 //Hardcoded Patra Inner Eye offsets
3617 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3618 //Broken 'Big enemy' animation style
3619 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3620 //Broken Attribute 31/32
3621 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3622 93 }
3623
3624
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 10) //Shared candle use limits
3625 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3626
3627
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 11) //No cross-screen return points
3628 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3629
3630
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 12)
3631 {
3632 //Old fire trail duration
3633 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3634 //Old Intro String in Ganon Room Behavior
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3636 93 else set_qr(qr_GANONINTRO,1);
3637 93 }
3638
3639
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
129 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3640 set_qr(qr_ANONE_NOANIM,1);
3641
3642
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 14) //Old Bridge Combo Behavior
3643 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3644
3645
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 15) //Broken Z3 Animation
3646 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3647
3648
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3649 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3650
3651
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 17)
3652 {
3653 //Old Quake/DrawYOffset behavior
3654 //set_qr(qr_OLD_DRAWOFFSET,1);
3655 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3656 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3657 93 }
3658
3659
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 18)
3660 {
3661 //Broken DrawScreen Derivative Functions
3662 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3663 //Scrolling Cancels Charge
3664 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3665 93 }
3666
3667
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3668 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3669
3670
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 20)
3671 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3672
3673
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 21)
3674 {
3675 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3676 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3677 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3678 93 set_qr(qr_OLD_BUG_NET,1);
3679 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3680 93 }
3681
3682
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 22)
3683 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3684
3685
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 23)
3686 93 set_qr(qr_OLD_HALF_MAGIC,1);
3687
3688
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 24)
3689 {
3690 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3691 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3692 93 }
3693
3694
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 25)
3695 {
3696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3697 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3698 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3699 93 }
3700
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 26)
3701 {
3702 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3703 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3704 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3705 93 }
3706
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3707 {
3708
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3709 27993 set_qr(q,0);
3710
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3711 10416 set_qr(q,0);
3712 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3713 93 }
3714
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 28)
3715 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3716
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 29)
3717 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3718
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 30)
3719 {
3720 95 set_qr(qr_DECO_2_YOFFSET,1);
3721 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3722 95 }
3723
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 31)
3724 {
3725 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3726 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3727 95 }
3728
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 32)
3729 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3730
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 33)
3731 95 set_qr(qr_NO_LIFT_SPRITE,1);
3732
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 34)
3733 {
3734 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3735 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3736 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3737 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3738 95 }
3739
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 96 times.
129 if(compatrule_version < 35)
3740 {
3741 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3742 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3743 96 }
3744
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 96 times.
129 if(compatrule_version < 36)
3745 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3746
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 37)
3747 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3748
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 38)
3749 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3750
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 39)
3751 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3752
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 40)
3753 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3754
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 41)
3755 99 set_qr(qr_BROKENHITBY,1);
3756
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 42)
3757 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3758
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 43)
3759 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3760
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 44)
3761 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3762
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 107 times.
129 if(compatrule_version < 45)
3763 107 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3764
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 107 times.
129 if(compatrule_version < 46)
3765 107 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3766
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 47)
3767 {
3768 110 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3769 110 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3770 110 }
3771
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 48)
3772 110 set_qr(qr_OLD_GUY_HANDLING,1);
3773
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 49)
3774 110 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(compatrule_version < 50)
3776 129 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(compatrule_version < 51)
3778 129 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if (compatrule_version < 52)
3780 129 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3781
3782 129 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3783
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if (s_version < 16)
3784 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3785
3786 129 memcpy(Header, &tempheader, sizeof(tempheader));
3787
3788 129 return 0;
3789 129 }
3790
3791 1084440 void init_msgstr(MsgStr *str)
3792 {
3793 1084440 str->s = "";
3794 1084440 str->s.shrink_to_fit();
3795 1084440 str->nextstring=0;
3796 1084440 str->tile=0;
3797 1084440 str->cset=0;
3798 1084440 str->trans=false;
3799 1084440 str->font=font_zfont;
3800 1084440 str->y=32;
3801 1084440 str->sfx=18;
3802 1084440 str->listpos=0;
3803 1084440 str->x=24;
3804 1084440 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3805 1084440 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3806 1084440 str->hspace=0;
3807 1084440 str->vspace=0;
3808 1084440 str->stringflags=0;
3809 1084440 str->margins[up] = 8;
3810 1084440 str->margins[down] = 0;
3811 1084440 str->margins[left] = 8;
3812 1084440 str->margins[right] = 0;
3813 1084440 str->portrait_tile = 0;
3814 1084440 str->portrait_cset = 0;
3815 1084440 str->portrait_x = 0;
3816 1084440 str->portrait_y = 0;
3817 1084440 str->portrait_tw = 1;
3818 1084440 str->portrait_th = 1;
3819 1084440 str->shadow_type = 0;
3820 1084440 str->shadow_color = 0;
3821 1084440 str->drawlayer = 6;
3822 1084440 }
3823
3824 129 void init_msgstrings(int32_t start, int32_t end)
3825 {
3826
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if(end <= start || end-start > msg_strings_size)
3827 return;
3828
3829
2/2
✓ Branch 0 taken 1056768 times.
✓ Branch 1 taken 129 times.
1056897 for(int32_t i=start; i<end; i++)
3830 {
3831 1056768 init_msgstr(&MsgStrings[i]);
3832 1056768 MsgStrings[i].listpos=i;
3833 1056768 }
3834
3835
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(start==0)
3836 {
3837 129 MsgStrings[0].s = "(None)";
3838 129 MsgStrings[0].listpos = 0;
3839 129 }
3840 129 }
3841
3842 129 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3843 {
3844 129 MsgStr tempMsgString;
3845
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_msgstr(&tempMsgString);
3846
3847 129 word temp_msg_count=0;
3848 word temp_expansion[16];
3849 129 memset(temp_expansion, 0, 16*sizeof(word));
3850 129 char buf[8193] = {0};
3851
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
3852 {
3853 byte tempbyte;
3854 4 int32_t strings_to_read=0;
3855
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3857 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3858 {
3859 4 strings_to_read=128;
3860 4 temp_msg_count=Header->old_str_count;
3861
3862 // Some sort of string count corruption seems to be common in old quests
3863
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3864 {
3865 temp_msg_count=128;
3866 }
3867 4 }
3868 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3869 {
3870 strings_to_read=255;
3871 temp_msg_count=Header->old_str_count;
3872 }
3873 else
3874 {
3875 if(!p_igetw(&temp_msg_count,f))
3876 {
3877 return qe_invalid;
3878 }
3879
3880 strings_to_read=temp_msg_count;
3881
3882 if(temp_msg_count >= msg_strings_size)
3883 {
3884 Z_message("Reallocating string buffer...\n");
3885
3886 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3887 // return qe_nomem;
3888
3889 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3890 delete[] MsgStrings;
3891 MsgStrings = new MsgStr[MAXMSGS];
3892 msg_strings_size = MAXMSGS;
3893 for(auto q = 0; q < msg_strings_size; ++q)
3894 {
3895 MsgStrings[q].clear();
3896 }
3897 }
3898 }
3899
3900 //reset the message strings
3901
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3902
3903
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3904 {
3905
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3906 512 tempMsgString.listpos = x;
3907
3908
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3909 {
3910 return qe_invalid;
3911 }
3912
3913 512 buf[74] = '\0';
3914
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3915
3916
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3917 {
3918 return qe_invalid;
3919 }
3920
3921
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3922 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3923 {
3924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3925
3926
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3927 {
3928 return qe_invalid;
3929 }
3930
3931
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3932 {
3933 return qe_invalid;
3934 }
3935 512 }
3936 else
3937 {
3938 if(!p_igetw(&tempMsgString.nextstring,f))
3939 {
3940 return qe_invalid;
3941 }
3942
3943 if(!pfread(temp_expansion,32,f))
3944 {
3945 return qe_invalid;
3946 }
3947 }
3948
3949
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3950 512 }
3951 4 }
3952 else
3953 {
3954 int32_t dummy_int;
3955 word s_version;
3956 word s_cversion;
3957
3958 //section version info
3959
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
3960 {
3961 return qe_invalid;
3962 }
3963
3964 125 FFCore.quest_format[vStrings] = s_version;
3965
3966
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
3967 {
3968 return qe_invalid;
3969 }
3970
3971 //al_trace("Strings version %d\n", s_version);
3972 //section size
3973
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy_int,f))
3974 {
3975 return qe_invalid;
3976 }
3977
3978 //finally... section data
3979
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_msg_count,f))
3980 {
3981 return qe_invalid;
3982 }
3983
3984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(temp_msg_count >= msg_strings_size)
3985 {
3986 Z_message("Reallocating string buffer...\n");
3987
3988 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3989 // return qe_nomem;
3990 delete[] MsgStrings;
3991 MsgStrings = new MsgStr[MAXMSGS];
3992 msg_strings_size = MAXMSGS;
3993 for(auto q = 0; q < msg_strings_size; ++q)
3994 {
3995 MsgStrings[q].clear();
3996 }
3997 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3998 }
3999
4000 //reset the message strings
4001
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 7)
4002
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
4003
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_msgstrings(0,msg_strings_size);
4004
4005 125 int32_t string_length=(s_version<2)?73:145;
4006
4007
2/2
✓ Branch 0 taken 27031 times.
✓ Branch 1 taken 125 times.
27156 for(int32_t i=0; i<temp_msg_count; i++)
4008 {
4009
1/2
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
27031 init_msgstr(&tempMsgString);
4010 27031 tempMsgString.listpos = i;
4011
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 26139 times.
27031 if(s_version > 8)
4012 {
4013
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&string_length,f))
4014 {
4015 return qe_invalid;
4016 }
4017 892 }
4018
4019
2/4
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27031 times.
27031 if (string_length < 0 || string_length > 8193)
4020 {
4021 return qe_invalid;
4022 }
4023
4024
2/2
✓ Branch 0 taken 26893 times.
✓ Branch 1 taken 138 times.
27031 if (string_length > 0)
4025 {
4026
2/4
✓ Branch 0 taken 26893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26893 times.
✗ Branch 3 not taken.
26893 if (!pfread(buf, string_length, f))
4027 {
4028 return qe_invalid;
4029 }
4030 26893 }
4031 else
4032 {
4033 138 buf[0] = 0;
4034 }
4035
4036
2/4
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27031 times.
✗ Branch 3 not taken.
27031 if(!p_igetw(&tempMsgString.nextstring,f))
4037 {
4038 return qe_invalid;
4039 }
4040
4041
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7930 times.
27031 if(s_version<2)
4042 {
4043 19101 buf[72] = '\0';
4044
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
4045 19101 }
4046 else
4047 {
4048 // June 2008: A bug corrupted the last 4 chars of a string.
4049 // Discard these.
4050
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(s_version<3)
4051 {
4052 for(int32_t j=140; j<144; j++)
4053 {
4054 buf[j] = '\0';
4055 }
4056 }
4057
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(string_length > 8192) string_length = 8192;
4058 7930 buf[string_length]='\0'; //Force-terminate
4059
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 tempMsgString.s = buf;
4060
4061
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 7038 times.
7930 if ( s_version >= 6 )
4062 {
4063
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&tempMsgString.tile,f))
4064 {
4065 return qe_invalid;
4066 }
4067 892 }
4068 else
4069 {
4070
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
4071 {
4072 return qe_invalid;
4073 }
4074 }
4075
4076
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.cset,f))
4077 {
4078 return qe_invalid;
4079 }
4080
4081 byte dummy_char;
4082
4083
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
4084 {
4085 return qe_invalid;
4086 }
4087
4088 7930 tempMsgString.trans=dummy_char!=0;
4089
4090
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.font,f))
4091 {
4092 return qe_invalid;
4093 }
4094
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7930 times.
7930 if(s_version < 5)
4096 {
4097 if(!p_getc(&tempMsgString.y,f))
4098 {
4099 return qe_invalid;
4100 }
4101 }
4102 else
4103 {
4104
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.x,f))
4105 {
4106 return qe_invalid;
4107 }
4108
4109
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.y,f))
4110 {
4111 return qe_invalid;
4112 }
4113
4114
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.w,f))
4115 {
4116 return qe_invalid;
4117 }
4118
4119
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.h,f))
4120 {
4121 return qe_invalid;
4122 }
4123
4124
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.hspace,f))
4125 {
4126 return qe_invalid;
4127 }
4128
4129
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.vspace,f))
4130 {
4131 return qe_invalid;
4132 }
4133
4134
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.stringflags,f))
4135 {
4136 return qe_invalid;
4137 }
4138 }
4139
4140
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 892 times.
7930 if(s_version >= 7)
4141 {
4142
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 3568 times.
4460 for(int32_t q = 0; q < 4; ++q)
4143 {
4144
2/4
✓ Branch 0 taken 3568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3568 times.
✗ Branch 3 not taken.
3568 if(!p_getc(&tempMsgString.margins[q],f))
4145 {
4146 return qe_invalid;
4147 }
4148 3568 }
4149
4150
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&tempMsgString.portrait_tile,f))
4151 {
4152 return qe_invalid;
4153 }
4154
4155
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_cset,f))
4156 {
4157 return qe_invalid;
4158 }
4159
4160
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_x,f))
4161 {
4162 return qe_invalid;
4163 }
4164
4165
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_y,f))
4166 {
4167 return qe_invalid;
4168 }
4169
4170
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_tw,f))
4171 {
4172 return qe_invalid;
4173 }
4174
4175
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_th,f))
4176 {
4177 return qe_invalid;
4178 }
4179 892 }
4180
4181
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 7038 times.
7930 if(s_version >= 8)
4182 {
4183
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.shadow_type,f))
4184 {
4185 return qe_invalid;
4186 }
4187
4188
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.shadow_color,f))
4189 {
4190 return qe_invalid;
4191 }
4192 892 }
4193
4194
2/2
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 7155 times.
7930 if(s_version >= 10)
4195 {
4196
2/4
✓ Branch 0 taken 775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
775 if(!p_getc(&tempMsgString.drawlayer,f))
4197 {
4198 return qe_invalid;
4199 }
4200 775 }
4201
4202
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.sfx,f))
4203 {
4204 return qe_invalid;
4205 }
4206
4207
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(s_version>3)
4208 {
4209
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.listpos,f))
4210 {
4211 return qe_invalid;
4212 }
4213 7930 }
4214 }
4215
4216
1/2
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
27031 MsgStrings[i].copyAll(tempMsgString);
4217 27031 }
4218 }
4219
4220 129 msg_count=temp_msg_count;
4221
4222 129 return 0;
4223 129 }
4224
4225 129 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4226 {
4227
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
4228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4229 {
4230 4 return 0;
4231 }
4232
4233 125 word temp_door_combo_set_count=0;
4234 DoorComboSet tempDoorComboSet;
4235 word dummy_word;
4236 int32_t dummy_long;
4237 byte padding;
4238 125 int32_t s_version = 0;
4239
4240
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4241 {
4242 32000 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4243 32000 }
4244
4245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(Header->zelda_version > 0x192)
4246 {
4247 //section version info
4248
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4249 {
4250 return qe_invalid;
4251 }
4252
4253 125 FFCore.quest_format[vDoors] = s_version;
4254
4255 //al_trace("Door combo sets version %d\n", dummy_word);
4256
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy_word,f))
4257 {
4258 return qe_invalid;
4259 }
4260
4261 //section size
4262
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy_long,f))
4263 {
4264 return qe_invalid;
4265 }
4266 125 }
4267
4268 //finally... section data
4269
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_door_combo_set_count,f))
4270 {
4271 return qe_invalid;
4272 }
4273
4274
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4275 {
4276 return qe_invalid;
4277 }
4278
4279
2/2
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 125 times.
1126 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4280 {
4281 1001 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4282
4283 //name
4284
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4285 {
4286 return qe_invalid;
4287 }
4288
4289
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4290 {
4291 if(!p_getc(&padding,f))
4292 {
4293 return qe_invalid;
4294 }
4295 }
4296
4297 //up door
4298
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4299 {
4300
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4301 {
4302
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4303 {
4304 return qe_invalid;
4305 }
4306 36036 }
4307 9009 }
4308
4309
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4310 {
4311
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4312 {
4313
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4314 {
4315 return qe_invalid;
4316 }
4317 36036 }
4318 9009 }
4319
4320 //down door
4321
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4322 {
4323
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4324 {
4325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36036 times.
36036 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4326 {
4327 return qe_invalid;
4328 }
4329 36036 }
4330 9009 }
4331
4332
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4333 {
4334
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4335 {
4336
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4337 {
4338 return qe_invalid;
4339 }
4340 36036 }
4341 9009 }
4342
4343 //left door
4344
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4345 {
4346
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4347 {
4348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54054 times.
54054 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4349 {
4350 return qe_invalid;
4351 }
4352 54054 }
4353 9009 }
4354
4355
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4356 {
4357
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4358 {
4359
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4360 {
4361 return qe_invalid;
4362 }
4363 54054 }
4364 9009 }
4365
4366 //right door
4367
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4368 {
4369
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4370 {
4371
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4372 {
4373 return qe_invalid;
4374 }
4375 54054 }
4376 9009 }
4377
4378
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4379 {
4380
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4381 {
4382
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4383 {
4384 return qe_invalid;
4385 }
4386 54054 }
4387 9009 }
4388
4389 //up bomb rubble
4390
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4391 {
4392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4393 {
4394 return qe_invalid;
4395 }
4396 2002 }
4397
4398
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4399 {
4400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4401 {
4402 return qe_invalid;
4403 }
4404 2002 }
4405
4406 //down bomb rubble
4407
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4408 {
4409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4410 {
4411 return qe_invalid;
4412 }
4413 2002 }
4414
4415
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4416 {
4417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4418 {
4419 return qe_invalid;
4420 }
4421 2002 }
4422
4423 //left bomb rubble
4424
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4425 {
4426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4427 {
4428 return qe_invalid;
4429 }
4430 3003 }
4431
4432
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4433 {
4434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4435 {
4436 return qe_invalid;
4437 }
4438 3003 }
4439
4440
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4441 {
4442 if(!p_getc(&padding,f))
4443 {
4444 return qe_invalid;
4445 }
4446
4447 }
4448
4449 //right bomb rubble
4450
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4451 {
4452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4453 {
4454 return qe_invalid;
4455 }
4456 3003 }
4457
4458
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4459 {
4460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4461 {
4462 return qe_invalid;
4463 }
4464 3003 }
4465
4466
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4467 {
4468 if(!p_getc(&padding,f))
4469 {
4470 return qe_invalid;
4471 }
4472 }
4473
4474 //walkthrough stuff
4475
2/2
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 1001 times.
5005 for(int32_t j=0; j<4; j++)
4476 {
4477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4004 times.
4004 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4478 {
4479 return qe_invalid;
4480 }
4481 4004 }
4482
4483
2/2
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 1001 times.
5005 for(int32_t j=0; j<4; j++)
4484 {
4485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4004 times.
4004 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4486 {
4487 return qe_invalid;
4488 }
4489 4004 }
4490
4491 //flags
4492
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4493 {
4494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.flags[j],f))
4495 {
4496 return qe_invalid;
4497 }
4498 2002 }
4499
4500
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4501 {
4502 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4503 {
4504 return qe_invalid;
4505 }
4506 }
4507
4508 1001 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4509 1001 }
4510
4511 125 door_combo_set_count=temp_door_combo_set_count;
4512
4513 125 return 0;
4514 129 }
4515
4516 int32_t count_dmaps()
4517 {
4518 int32_t i=MAXDMAPS-1;
4519 bool found=false;
4520
4521 while(i>=0 && !found)
4522 {
4523 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4524 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4525 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4526 found=true;
4527
4528 for(int32_t j=0; j<8; j++)
4529 {
4530 if(DMaps[i].grid[j]!=0)
4531
4532 found=true;
4533 }
4534
4535 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4536 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4537 found=true;
4538
4539 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4540 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4541 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4542 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4543 found=true;
4544
4545 if(!found)
4546 {
4547 i--;
4548 }
4549 }
4550
4551 return i+1;
4552 }
4553
4554
4555 int32_t count_shops(miscQdata *Misc)
4556 {
4557 int32_t i=NUM_SHOPS-1,j;
4558 bool found=false;
4559
4560 while(i>=0 && !found)
4561 {
4562 j=2;
4563
4564 while(j>=0 && !found)
4565 {
4566 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4567 {
4568 found=true;
4569 }
4570 else
4571 {
4572 j--;
4573 }
4574 }
4575
4576 if(Misc->shop[i].name[0]!=0)
4577 {
4578 found=true;
4579 }
4580
4581 if(!found)
4582 {
4583 i--;
4584 }
4585 }
4586
4587 return i+1;
4588 }
4589
4590 int32_t count_infos(miscQdata *Misc)
4591 {
4592 int32_t i=255,j;
4593 bool found=false;
4594
4595 while(i>=0 && !found)
4596 {
4597 j=2;
4598
4599 while(j>=0 && !found)
4600 {
4601 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4602 {
4603 found=true;
4604 }
4605 else
4606 {
4607 j--;
4608 }
4609 }
4610
4611 if(Misc->info[i].name[0]!=0)
4612 {
4613 found=true;
4614 }
4615
4616 if(!found)
4617 {
4618 i--;
4619 }
4620 }
4621
4622 return i+1;
4623 }
4624
4625 int32_t count_warprings(miscQdata *Misc)
4626 {
4627 int32_t i=15,j;
4628 bool found=false;
4629
4630 while(i>=0 && !found)
4631 {
4632 j=7;
4633
4634 while(j>=0 && !found)
4635 {
4636 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4637 {
4638 found=true;
4639 }
4640 else
4641 {
4642 j--;
4643 }
4644 }
4645
4646 if(!found)
4647 {
4648 i--;
4649 }
4650 }
4651
4652 return i+1;
4653 }
4654
4655 int32_t count_palcycles(miscQdata *Misc)
4656 {
4657 int32_t i=255,j;
4658 bool found=false;
4659
4660 while(i>=0 && !found)
4661 {
4662 j=2;
4663
4664 while(j>=0 && !found)
4665 {
4666 if(Misc->cycles[i][j].count!=0)
4667 {
4668 found=true;
4669 }
4670 else
4671 {
4672 j--;
4673 }
4674 }
4675
4676 if(!found)
4677 {
4678 i--;
4679 }
4680 }
4681
4682 return i+1;
4683 }
4684
4685 264713 void clear_screen(mapscr *temp_scr)
4686 {
4687 264713 temp_scr->zero_memory();
4688 264713 }
4689
4690 129 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4691 {
4692 129 word dmapstoread=0;
4693 dmap tempDMap;
4694
4695 int32_t dummy;
4696 129 word s_version=0, s_cversion=0;
4697 byte padding;
4698
4699
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<max_dmaps; i++)
4700 {
4701 66048 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4702 66048 sprintf(DMaps[start_dmap+i].title," ");
4703 66048 sprintf(DMaps[start_dmap+i].intro," ");
4704 66048 DMaps[start_dmap+i].type |= dmCAVE;
4705 66048 }
4706
4707
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 4 times.
129 if(!Header || Header->zelda_version > 0x192)
4708 {
4709 //section version info
4710
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4711 {
4712 return qe_invalid;
4713 }
4714
4715 125 FFCore.quest_format[vDMaps] = s_version;
4716
4717 //al_trace("DMaps version %d\n", s_version);
4718
4719
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
4720 {
4721 return qe_invalid;
4722 }
4723
4724 //section size
4725
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
4726 {
4727 return qe_invalid;
4728 }
4729
4730 //finally... section data
4731
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dmapstoread,f))
4732 {
4733 return qe_invalid;
4734 }
4735 125 }
4736 else
4737 {
4738
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4739 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4740 {
4741 4 dmapstoread=32;
4742 4 }
4743 else if(s_version <= 4)
4744 {
4745 dmapstoread=OLDMAXDMAPS;
4746 }
4747 else
4748 {
4749 dmapstoread=MAXDMAPS;
4750 }
4751 }
4752
4753
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, max_dmaps);
4754
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4755
4756
2/2
✓ Branch 0 taken 61056 times.
✓ Branch 1 taken 129 times.
61185 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4757 {
4758 61056 memset(&tempDMap,0,sizeof(dmap));
4759 61056 sprintf(tempDMap.title," ");
4760 61056 sprintf(tempDMap.intro," ");
4761
4762
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.map,f))
4763 {
4764 return qe_invalid;
4765 }
4766
4767
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version <= 4)
4768 {
4769 byte tempbyte;
4770
4771
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4772 {
4773 return qe_invalid;
4774 }
4775
4776 3200 tempDMap.level=(word)tempbyte;
4777 3200 }
4778 else
4779 {
4780
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.level,f))
4781 {
4782 return qe_invalid;
4783 }
4784 }
4785
4786
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.xoff,f))
4787 {
4788 return qe_invalid;
4789 }
4790
4791
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.compass,f))
4792 {
4793 return qe_invalid;
4794 }
4795
4796
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version > 8) // February 2009
4797 {
4798
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.color,f))
4799 {
4800 return qe_invalid;
4801 }
4802 57856 }
4803 else
4804 {
4805 byte tempbyte;
4806
4807
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4808 {
4809 return qe_invalid;
4810 }
4811
4812 3200 tempDMap.color = (word)tempbyte;
4813 }
4814
4815
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.midi,f))
4816 {
4817 return qe_invalid;
4818 }
4819
4820
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.cont,f))
4821 {
4822 return qe_invalid;
4823 }
4824
4825
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.type,f))
4826 {
4827 return qe_invalid;
4828 }
4829
4830
4/4
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 60226 times.
✓ Branch 2 taken 818 times.
✓ Branch 3 taken 12 times.
61886 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4831
1/2
✓ Branch 0 taken 830 times.
✗ Branch 1 not taken.
830 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4832 818 tempDMap.xoff = 0;
4833
4834
2/2
✓ Branch 0 taken 488448 times.
✓ Branch 1 taken 61056 times.
549504 for(int32_t j=0; j<8; j++)
4835 {
4836
1/2
✓ Branch 0 taken 488448 times.
✗ Branch 1 not taken.
488448 if(!p_getc(&tempDMap.grid[j],f))
4837 {
4838 return qe_invalid;
4839 }
4840 488448 }
4841
4842
4/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4843 {
4844
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4845 {
4846 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4847 38 }
4848
4849
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4850 {
4851 4 tempDMap.cont-=tempDMap.xoff;
4852 4 tempDMap.compass-=tempDMap.xoff;
4853 4 }
4854
4855 //forgotten -DD
4856
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4857 {
4858 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4859 90 }
4860 128 }
4861 else
4862 {
4863
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4864 {
4865 return qe_invalid;
4866 }
4867
4868
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f))
4869 {
4870 return qe_invalid;
4871 }
4872
4873
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4874 {
4875 return qe_invalid;
4876 }
4877
4878
3/8
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60928 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4879 {
4880 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4881 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4882
4883 continue;
4884 }
4885
4886
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4887 {
4888 if(!p_getc(&padding,f))
4889 {
4890 return qe_invalid;
4891 }
4892 }
4893
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4894 {
4895
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4896 {
4897 return qe_invalid;
4898 }
4899 18432 }
4900 else
4901 {
4902
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4903 {
4904 return qe_invalid;
4905 }
4906 }
4907
4908
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_1_cset,f))
4909 {
4910 return qe_invalid;
4911 }
4912
4913
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4914 {
4915 if(!p_getc(&padding,f))
4916 {
4917 return qe_invalid;
4918 }
4919 }
4920
4921
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4922 {
4923
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4924 {
4925 return qe_invalid;
4926 }
4927 18432 }
4928 else
4929 {
4930
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4931 {
4932 return qe_invalid;
4933 }
4934 }
4935
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_2_cset,f))
4936 {
4937 return qe_invalid;
4938 }
4939
4940
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4941 {
4942 if(!p_getc(&padding,f))
4943 {
4944 return qe_invalid;
4945 }
4946 }
4947
4948
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4949 {
4950
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4951 {
4952 return qe_invalid;
4953 }
4954 18432 }
4955 else
4956 {
4957
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4958 {
4959 return qe_invalid;
4960 }
4961 }
4962
4963
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_1_cset,f))
4964 {
4965 return qe_invalid;
4966 }
4967
4968
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4969 {
4970
4971 if(!p_getc(&padding,f))
4972 {
4973 return qe_invalid;
4974 }
4975 }
4976
4977
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4978 {
4979
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4980 {
4981 return qe_invalid;
4982 }
4983 18432 }
4984 else
4985 {
4986
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4987 {
4988 return qe_invalid;
4989 }
4990 }
4991
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_2_cset,f))
4992 {
4993 return qe_invalid;
4994 }
4995
4996
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4997 {
4998 return qe_invalid;
4999 }
5000 }
5001
5002
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>1)
5003 {
5004
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.tmusictrack,f))
5005 {
5006 return qe_invalid;
5007 }
5008
5009
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.active_subscreen,f))
5010 {
5011 return qe_invalid;
5012 }
5013
5014
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.passive_subscreen,f))
5015 {
5016 return qe_invalid;
5017 }
5018 57856 }
5019
5020
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>2)
5021 {
5022 byte di[32];
5023
5024
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&di, 32, f)) return qe_invalid;
5025
5026
2/2
✓ Branch 0 taken 14811136 times.
✓ Branch 1 taken 57856 times.
14868992 for(int32_t j=0; j<MAXITEMS; j++)
5027 {
5028
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14811129 times.
14811136 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5029 14811129 else tempDMap.disableditems[j]=0;
5030 14811136 }
5031 57856 }
5032
5033
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version >= 6)
5034 {
5035
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&tempDMap.flags,f))
5036 {
5037 return qe_invalid;
5038 }
5039 57856 }
5040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
5041 {
5042 char temp;
5043
5044 if(!p_getc(&temp,f))
5045 {
5046 return qe_invalid;
5047 }
5048
5049 tempDMap.flags = temp;
5050 }
5051
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5052 {
5053 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5054 816 }
5055 else
5056 2384 tempDMap.flags=0;
5057
5058
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<7)
5059 {
5060
3/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5061 816 tempDMap.flags|= dmfVIEWMAP;
5062 3200 }
5063
5064
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<8)
5065 {
5066
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5067 {
5068 609 tempDMap.type &= ~dmDNGN;
5069 609 tempDMap.type |= dmCAVE;
5070 609 }
5071
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5072 {
5073 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5074 1736 }
5075 3200 }
5076
5077
5/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 60928 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 60928 times.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5078 60928 && (Header->zelda_version < 0x193))
5079 {
5080 if(!p_getc(&padding,f))
5081 {
5082 return qe_invalid;
5083 }
5084 }
5085
5086
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 10)
5087 {
5088
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempDMap.sideview,f))
5089 {
5090 return qe_invalid;
5091 }
5092 18432 }
5093
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version < 10) tempDMap.sideview = 0;
5094
5095 //Dmap Scripts
5096
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 12)
5097 {
5098
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.script,f))
5099 {
5100 return qe_invalid;
5101 }
5102
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5103 {
5104
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.initD[q],f))
5105 {
5106 return qe_invalid;
5107 }
5108 147456 }
5109 18432 }
5110
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 12 )
5111 {
5112 42624 tempDMap.script = 0;
5113
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5114 {
5115 340992 tempDMap.initD[q] = 0;
5116 340992 }
5117 42624 }
5118
5119
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 13)
5120 {
5121
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5122 {
5123
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
5124 {
5125
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.initD_label[q][w],f))
5126 {
5127 return qe_invalid;
5128 }
5129 9584640 }
5130 147456 }
5131 18432 }
5132
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 13 )
5133 {
5134 42624 tempDMap.script = 0;
5135
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5136 {
5137
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5138 22164480 tempDMap.initD_label[q][w] = 0;
5139 340992 }
5140 42624 }
5141
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 14)
5142 {
5143
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.active_sub_script,f))
5144 {
5145 return qe_invalid;
5146 }
5147
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.passive_sub_script,f))
5148 {
5149 return qe_invalid;
5150 }
5151
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5152 {
5153
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.sub_initD[q],f))
5154 {
5155 return qe_invalid;
5156 }
5157 147456 }
5158
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5159 {
5160
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5161 {
5162
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5163 {
5164 return qe_invalid;
5165 }
5166 9584640 }
5167 147456 }
5168 18432 }
5169 else
5170 {
5171 42624 tempDMap.active_sub_script = 0;
5172 42624 tempDMap.passive_sub_script = 0;
5173
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5174 {
5175 340992 tempDMap.sub_initD[q] = 0;
5176
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5177 22164480 tempDMap.sub_initD_label[q][w] = 0;
5178 340992 }
5179 }
5180
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 15)
5181 {
5182
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.onmap_script,f))
5183 {
5184 return qe_invalid;
5185 }
5186
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5187 {
5188
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5189 {
5190 return qe_invalid;
5191 }
5192 147456 }
5193
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5194 {
5195
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5196 {
5197
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5198 {
5199 return qe_invalid;
5200 }
5201 9584640 }
5202 147456 }
5203 18432 }
5204 else
5205 {
5206 42624 tempDMap.onmap_script = 0;
5207
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5208 {
5209 340992 tempDMap.onmap_initD[q] = 0;
5210
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5211 {
5212 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5213 22164480 }
5214 340992 }
5215 }
5216
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 16)
5217 {
5218
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.mirrorDMap,f))
5219 {
5220 return qe_invalid;
5221 }
5222 18432 }
5223 else
5224 {
5225 42624 tempDMap.mirrorDMap = -1;
5226 }
5227
5228
2/2
✓ Branch 0 taken 51328 times.
✓ Branch 1 taken 9728 times.
61056 if (s_version >= 17)
5229 {
5230 // Reserved for z3.
5231 9728 }
5232
5233 // Enhanced music loop points
5234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61056 times.
61056 if (s_version >= 18)
5235 {
5236 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5237 {
5238 return qe_invalid;
5239 }
5240 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5241 {
5242 return qe_invalid;
5243 }
5244 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5245 {
5246 return qe_invalid;
5247 }
5248 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5249 {
5250 return qe_invalid;
5251 }
5252 }
5253 else
5254 {
5255 61056 tempDMap.tmusic_loop_start = 0;
5256 61056 tempDMap.tmusic_loop_end = 0;
5257 61056 tempDMap.tmusic_xfade_in = 0;
5258 61056 tempDMap.tmusic_xfade_out = 0;
5259 }
5260
5261 61056 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5262 61056 }
5263
5264 129 return 0;
5265 129 }
5266
5267 113 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5268 {
5269 //these are here to bypass compiler warnings about unused arguments
5270 113 Header=Header;
5271
5272 miscQdata temp_misc;
5273 113 word s_version=0, s_cversion=0;
5274 113 int32_t tempsize=0;
5275 word dummyw;
5276
5277 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5278
5279 //section version info
5280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5281 {
5282 return qe_invalid;
5283 }
5284
5285 113 FFCore.quest_format[vColours] = s_version;
5286
5287 113 al_trace("Misc Colours section version: %d\n", s_version);
5288
5289 //al_trace("Misc. colors version %d\n", s_version);
5290
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5291 {
5292 return qe_invalid;
5293 }
5294
5295
5296 //section size
5297
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5298 {
5299 return qe_invalid;
5300 }
5301
5302 //finally... section data
5303 113 readsize=0;
5304
5305
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.text,f))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.caption,f))
5311 {
5312 return qe_invalid;
5313 }
5314
5315
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overw_bg,f))
5316 {
5317 return qe_invalid;
5318 }
5319
5320
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5321 {
5322 return qe_invalid;
5323 }
5324
5325
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5326 {
5327 return qe_invalid;
5328 }
5329
5330
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.cave_fg,f))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_dk,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_goal,f))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_lt,f))
5346 {
5347 return qe_invalid;
5348 }
5349
5350
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_dk,f))
5351 {
5352 return qe_invalid;
5353 }
5354
5355
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5356 {
5357 return qe_invalid;
5358 }
5359
5360
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_color,f))
5361 {
5362 return qe_invalid;
5363 }
5364
5365
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.hero_dot,f))
5366 {
5367 return qe_invalid;
5368 }
5369
5370
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5371 {
5372 return qe_invalid;
5373 }
5374
5375
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5376 {
5377 return qe_invalid;
5378 }
5379
5380
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5381 {
5382 return qe_invalid;
5383 }
5384
5385
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5386 {
5387 return qe_invalid;
5388 }
5389
5390
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5391 {
5392 return qe_invalid;
5393 }
5394
5395
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5396 {
5397 return qe_invalid;
5398 }
5399
5400
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5401 {
5402 return qe_invalid;
5403 }
5404
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 4)
5405 {
5406
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5407 return qe_invalid;
5408 77 temp_misc.colors.triforce_tile = dummyw;
5409
5410
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5411 return qe_invalid;
5412 77 temp_misc.colors.triframe_tile = dummyw;
5413
5414
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5415 return qe_invalid;
5416 77 temp_misc.colors.overworld_map_tile = dummyw;
5417
5418
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5419 return qe_invalid;
5420 77 temp_misc.colors.dungeon_map_tile = dummyw;
5421
5422
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5423 return qe_invalid;
5424 77 temp_misc.colors.blueframe_tile = dummyw;
5425
5426
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5427 return qe_invalid;
5428 77 temp_misc.colors.HCpieces_tile = dummyw;
5429 77 }
5430
5431
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5432 {
5433 return qe_invalid;
5434 }
5435
5436
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5437 {
5438 return qe_invalid;
5439 }
5440
5441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 2)
5442 {
5443 temp_misc.colors.msgtext = 0x01;
5444 }
5445 else
5446 {
5447
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.msgtext, f))
5448 {
5449 return qe_invalid;
5450 }
5451 }
5452
5453
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if ( s_version >= 3 ) //expanded tile pages to 825
5454 {
5455
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5456 {
5457 return qe_invalid;
5458 }
5459
5460
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5461 {
5462 return qe_invalid;
5463 }
5464
5465
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5466 {
5467 return qe_invalid;
5468 }
5469
5470
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5471 {
5472 return qe_invalid;
5473 }
5474
5475
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5476 {
5477 return qe_invalid;
5478 }
5479
5480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5481 {
5482 return qe_invalid;
5483 }
5484 36 }
5485
5486 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5487
5488 113 return 0;
5489 113 }
5490
5491 113 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5492 {
5493 miscQdata temp_misc;
5494 113 word s_version=0, s_cversion=0;
5495 byte icons;
5496 113 int32_t tempsize=0;
5497
5498 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5499
5500 //section version info
5501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5502 {
5503 return qe_invalid;
5504 }
5505
5506 113 FFCore.quest_format[vIcons] = s_version;
5507
5508 //al_trace("Game icons version %d\n", s_version);
5509
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5510 {
5511 return qe_invalid;
5512 }
5513
5514
5515 //section size
5516
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5517 {
5518 return qe_invalid;
5519 }
5520
5521 //finally... section data
5522 113 readsize=0;
5523
5524 113 icons=4;
5525
5526
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 10 )
5527 {
5528
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<icons; i++)
5529 {
5530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&temp_misc.icons[i],f))
5531 {
5532 return qe_invalid;
5533 }
5534 144 }
5535 36 }
5536 else
5537 {
5538
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5539 {
5540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5541 {
5542 return qe_invalid;
5543 }
5544 308 }
5545 }
5546
5547 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5548
5549 113 return 0;
5550 113 }
5551
5552 129 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5553 {
5554 129 word maxinfos=256;
5555 129 word maxshops=256;
5556 129 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5557 129 word ponds=16, pondsize=72, expansionsize=98*2;
5558 byte tempbyte, padding;
5559 miscQdata temp_misc;
5560 129 word s_version=0, s_cversion=0;
5561 word swaptmp;
5562 129 int32_t tempsize=0;
5563
5564 129 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5565
5566
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5567 {
5568 33024 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5569 33024 }
5570
5571
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5572 {
5573 33024 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5574 33024 }
5575
5576
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5577 {
5578 //section version info
5579
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
5580 {
5581 return qe_invalid;
5582 }
5583
5584 125 FFCore.quest_format[vMisc] = s_version;
5585
5586 //al_trace("Misc. data version %d\n", s_version);
5587
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
5588 {
5589 return qe_invalid;
5590 }
5591
5592
5593 //section size
5594
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&tempsize,f))
5595 {
5596 return qe_invalid;
5597 }
5598 125 }
5599
5600 //finally... section data
5601 129 readsize=0;
5602
5603 //shops
5604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5605 {
5606
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&shops,f))
5607 {
5608 return qe_invalid;
5609 }
5610 125 }
5611
5612
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(shops >= 0 && shops <= NUM_SHOPS))
5613 {
5614 return qe_invalid;
5615 }
5616
5617
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 129 times.
1585 for(int32_t i=0; i<shops; i++)
5618 {
5619
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1233 times.
1456 if(s_version > 6)
5620 {
5621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5622 {
5623 return qe_invalid;
5624 }
5625 1233 }
5626
5627
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 1456 times.
5824 for(int32_t j=0; j<3; j++)
5628 {
5629
1/2
✓ Branch 0 taken 4368 times.
✗ Branch 1 not taken.
4368 if(!p_getc(&temp_misc.shop[i].item[j],f))
5630 {
5631 return qe_invalid;
5632 }
5633
5634
2/2
✓ Branch 0 taken 3699 times.
✓ Branch 1 taken 669 times.
4368 if(s_version < 4)
5635 {
5636 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5637 669 }
5638 4368 }
5639
5640
2/2
✓ Branch 0 taken 1392 times.
✓ Branch 1 taken 64 times.
1456 if(Header->zelda_version < 0x193)
5641 {
5642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5643 {
5644 return qe_invalid;
5645 }
5646 64 }
5647
5648
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 1456 times.
5824 for(int32_t j=0; j<3; j++)
5649 {
5650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4368 times.
4368 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5651 {
5652 return qe_invalid;
5653 }
5654 4368 }
5655
5656
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1233 times.
1456 if(s_version > 3)
5657 {
5658
2/2
✓ Branch 0 taken 3699 times.
✓ Branch 1 taken 1233 times.
4932 for(int32_t j=0; j<3; j++)
5659 {
5660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3699 times.
3699 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5661 return qe_invalid;
5662 3699 }
5663 1233 }
5664
5665 /*
5666 if(s_version < 8)
5667 {
5668 for(int32_t j=0; j<3; j++)
5669 {
5670 (&temp_misc.shop[i].str[j])=0; //initialise.
5671 }
5672 }
5673 */
5674 1456 }
5675
5676 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5677
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5678 {
5679
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5680 {
5681
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 96081 times.
162129 for(int32_t k=0; k<2-j; k++)
5682 {
5683 96081 if(temp_misc.shop[i].hasitem[k]==0)
5684 {
5685 96081 swaptmp = temp_misc.shop[i].item[k];
5686 96081 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5687 96081 temp_misc.shop[i].item[k+1] = swaptmp;
5688 96081 swaptmp = temp_misc.shop[i].price[k];
5689 96081 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5690 96081 temp_misc.shop[i].price[k+1] = swaptmp;
5691 96081 swaptmp = temp_misc.shop[i].hasitem[k];
5692 96081 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5693 96081 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5694 96081 }
5695 96081 }
5696 66048 }
5697 33024 }
5698
5699 //infos
5700
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5701 {
5702
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&infos,f))
5703 {
5704 return qe_invalid;
5705 }
5706 125 }
5707
5708
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(infos >= 0 && infos <= NUM_INFOS))
5709 {
5710 return qe_invalid;
5711 }
5712
5713
5714
2/2
✓ Branch 0 taken 1767 times.
✓ Branch 1 taken 129 times.
1896 for(int32_t i=0; i<infos; i++)
5715 {
5716
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1667 times.
1767 if(s_version > 6)
5717 {
5718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1667 times.
1667 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5719 {
5720 return qe_invalid;
5721 }
5722 1667 }
5723
5724
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 1767 times.
7068 for(int32_t j=0; j<3; j++)
5725 {
5726
2/4
✓ Branch 0 taken 5109 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5301 if((Header->zelda_version < 0x192)||
5727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5109 times.
5109 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5728 {
5729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5730 {
5731 return qe_invalid;
5732 }
5733
5734 192 temp_misc.info[i].str[j]=tempbyte;
5735 192 }
5736 else
5737 {
5738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5109 times.
5109 if(!p_igetw(&temp_misc.info[i].str[j],f))
5739 {
5740 return qe_invalid;
5741 }
5742 }
5743 5301 }
5744
5745
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 64 times.
1767 if(Header->zelda_version < 0x193)
5746 {
5747
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5748 {
5749 return qe_invalid;
5750 }
5751 64 }
5752
5753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767 if((Header->zelda_version == 0x192)&&(Header->build>145))
5754 {
5755 if(!p_getc(&padding,f))
5756 {
5757 return qe_invalid;
5758 }
5759 }
5760
5761
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 1767 times.
7068 for(int32_t j=0; j<3; j++)
5762 {
5763
1/2
✓ Branch 0 taken 5301 times.
✗ Branch 1 not taken.
5301 if(!p_igetw(&temp_misc.info[i].price[j],f))
5764 {
5765 return qe_invalid;
5766 }
5767 5301 }
5768 1767 }
5769
5770 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5771
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5772 {
5773
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5774 {
5775
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 66048 times.
165120 for(int32_t k=0; k<2-j; k++)
5776 {
5777
2/2
✓ Branch 0 taken 2094 times.
✓ Branch 1 taken 96978 times.
99072 if(temp_misc.info[i].str[k]==0)
5778 {
5779 96978 swaptmp = temp_misc.info[i].str[k];
5780 96978 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5781 96978 temp_misc.info[i].str[k+1] = swaptmp;
5782 96978 swaptmp = temp_misc.info[i].price[k];
5783 96978 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5784 96978 temp_misc.info[i].price[k+1] = swaptmp;
5785 96978 }
5786 99072 }
5787 66048 }
5788 33024 }
5789
5790
5791 //warp rings
5792
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version > 5)
5793 113 warprings++;
5794
5795
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5796 {
5797
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&warprings,f))
5798 {
5799 return qe_invalid;
5800 }
5801
5802
3/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 38 times.
125 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5803 {
5804 // return qe_invalid;
5805 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5806 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5807 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5808 38 }
5809 125 }
5810
5811
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 129 times.
1427 for(int32_t i=0; i<warprings; i++)
5812 {
5813 // See above comment on the `warprings` range check.
5814 1298 bool keepdata = i < NUM_WARP_RINGS;
5815
5816
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5817 {
5818
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9666 times.
11458 if(s_version <= 3)
5819 {
5820
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5821 {
5822 return qe_invalid;
5823 }
5824
5825
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5826 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5827 1792 }
5828 else
5829 {
5830 word tempword;
5831
1/2
✓ Branch 0 taken 9666 times.
✗ Branch 1 not taken.
9666 if(!p_igetw(&tempword,f))
5832 {
5833 return qe_invalid;
5834 }
5835
5836
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9153 times.
9666 if (keepdata)
5837 9153 temp_misc.warp[i].dmap[j] = tempword;
5838 }
5839 11458 }
5840
5841
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5842 {
5843
1/2
✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
11458 if(!p_getc(&tempbyte,f))
5844 {
5845 return qe_invalid;
5846 }
5847
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10273 times.
11458 if (keepdata)
5848 10273 temp_misc.warp[i].scr[j] = tempbyte;
5849 11458 }
5850
5851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1298 times.
1298 if(!p_getc(&tempbyte,f))
5852 {
5853 return qe_invalid;
5854 }
5855
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1157 times.
1298 if (keepdata)
5856 1157 temp_misc.warp[i].size = tempbyte;
5857
5858
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 32 times.
1298 if(Header->zelda_version < 0x193)
5859 {
5860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5861 {
5862 return qe_invalid;
5863 }
5864 32 }
5865 1298 }
5866
5867 //palette cycles
5868
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5869 {
5870
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5871 {
5872
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5873 {
5874 3072 temp_misc.cycles[i][j].first=0;
5875 3072 temp_misc.cycles[i][j].count=0;
5876 3072 temp_misc.cycles[i][j].speed=0;
5877 3072 }
5878 1024 }
5879
5880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5881 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5882 {
5883 4 palcycles=16;
5884 4 }
5885
5886
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5887 {
5888
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5889 {
5890
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5901 {
5902 return qe_invalid;
5903 }
5904 192 }
5905 64 }
5906 4 }
5907
5908 //Wind warps are now just another warp ring.
5909
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version <= 5)
5910 {
5911
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5912 {
5913
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5914 {
5915 return qe_invalid;
5916 }
5917 12 }
5918
5919
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5925 {
5926
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5927 {
5928
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5929 {
5930 return qe_invalid;
5931 }
5932
5933 135 temp_misc.warp[8].dmap[i]=tempbyte;
5934 135 }
5935 else
5936 {
5937 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5938 {
5939 return qe_invalid;
5940 }
5941 }
5942
5943
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5944 {
5945 return qe_invalid;
5946 }
5947
5948 135 temp_misc.warp[8].size = 9;
5949
5950
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5951 {
5952 if(!p_getc(&tempbyte,f))
5953 {
5954 return qe_invalid;
5955 }
5956 }
5957 135 }
5958 16 }
5959
5960
5961 //triforce pieces
5962
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<triforces; i++)
5963 {
5964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(!p_getc(&temp_misc.triforce[i],f))
5965 {
5966 return qe_invalid;
5967 }
5968 1032 }
5969
5970 //misc color data
5971
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<3)
5972 {
5973
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
6014 {
6015 return qe_invalid;
6016 }
6017
6018
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
6019 {
6020 return qe_invalid;
6021 }
6022
6023
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
6024 {
6025 return qe_invalid;
6026 }
6027
6028
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
6029 {
6030 return qe_invalid;
6031 }
6032
6033
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6034 {
6035 return qe_invalid;
6036 }
6037
6038
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6039 {
6040 return qe_invalid;
6041 }
6042
6043
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6044 {
6045 return qe_invalid;
6046 }
6047
6048
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6049 {
6050 return qe_invalid;
6051 }
6052
6053
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6054 {
6055 return qe_invalid;
6056 }
6057
6058
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6059 {
6060 return qe_invalid;
6061 }
6062
6063
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6064 {
6065 return qe_invalid;
6066 }
6067
6068
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6069 {
6070 return qe_invalid;
6071 }
6072
6073
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6074 {
6075 return qe_invalid;
6076 }
6077
6078
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6079 {
6080 return qe_invalid;
6081 }
6082
6083
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6084 {
6085 return qe_invalid;
6086 }
6087
6088
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6089 {
6090 return qe_invalid;
6091 }
6092
6093
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6094 {
6095 return qe_invalid;
6096 }
6097
6098
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6099 {
6100 return qe_invalid;
6101 }
6102
6103
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6104 {
6105 return qe_invalid;
6106 }
6107
6108 16 temp_misc.colors.msgtext = 0x01;
6109
6110
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6111 {
6112
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6113 {
6114
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6115 {
6116 return qe_invalid;
6117 }
6118 28 }
6119 4 }
6120
6121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6122 {
6123 for(int32_t i=0; i<256; i++)
6124 {
6125 if(!p_getc(&tempbyte,f))
6126 {
6127 return qe_invalid;
6128 }
6129 }
6130 }
6131
6132
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6133 {
6134 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6135 {
6136 return qe_invalid;
6137 }
6138 }
6139
6140 //save game icons
6141
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6143 {
6144 4 icons=3;
6145 4 }
6146
6147
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6148 {
6149
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6150 {
6151 return qe_invalid;
6152 }
6153 60 }
6154 16 }
6155
6156
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
6157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6158 {
6159 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6160
6161 4 return 0;
6162 }
6163
6164 //pond information
6165
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6166 {
6167 if((Header->zelda_version == 0x192)&&(Header->build<146))
6168 {
6169 pondsize=25;
6170 }
6171
6172 for(int32_t i=0; i<ponds; i++)
6173 {
6174 for(int32_t j=0; j<pondsize; j++)
6175 {
6176 if(!p_getc(&tempbyte,f))
6177 {
6178 return qe_invalid;
6179
6180 }
6181 }
6182 }
6183 }
6184
6185 //end string
6186
1/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version < 0x192)||
6187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6188 {
6189 if(!p_getc(&tempbyte,f))
6190 {
6191 return qe_invalid;
6192 }
6193
6194 temp_misc.endstring=tempbyte;
6195
6196 if(!p_getc(&tempbyte,f))
6197 {
6198 return qe_invalid;
6199 }
6200 }
6201 else
6202 {
6203
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_misc.endstring,f))
6204 {
6205 return qe_invalid;
6206 }
6207 }
6208
6209 //expansion
6210
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6211 {
6212 if((Header->zelda_version == 0x192)&&(Header->build<73))
6213 {
6214 expansionsize=99*2;
6215 }
6216
6217 for(int32_t i=0; i<expansionsize; i++)
6218 {
6219 if(!p_getc(&tempbyte,f))
6220 {
6221 return qe_invalid;
6222 }
6223 }
6224 }
6225 //shops v8
6226
6227
6228
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 8)
6229 {
6230
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 36 times.
564 for(int32_t i=0; i<shops; i++)
6231 {
6232
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 528 times.
2112 for(int32_t j=0; j<3; j++)
6233 {
6234
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6235 return qe_invalid;
6236 1584 }
6237 528 }
6238 36 }
6239
6240 125 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6241 125 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6242 125 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6243
6244 //v9 includes quest misc[32]
6245
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 9)
6246 {
6247
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6248 {
6249
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
1152 if(!p_igetl(&temp_misc.questmisc[q],f))
6250 return qe_invalid;
6251 1152 }
6252
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6253 {
6254
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 1152 times.
148608 for ( int32_t j = 0; j < 128; j++ )
6255
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6256 return qe_invalid;
6257 1152 }
6258 36 }
6259
6260
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 11 )
6261 {
6262
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6263 return qe_invalid;
6264 36 }
6265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6266 {
6267 89 temp_misc.zscript_last_compiled_version = -1;
6268 89 }
6269
6270 125 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6271
6272
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 12)
6273 {
6274 byte spr;
6275
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sprMAX; ++q)
6276 {
6277
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&spr,f))
6278 return qe_invalid;
6279 9216 temp_misc.sprites[q] = spr;
6280 9216 }
6281 36 }
6282 else
6283 {
6284 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6285 //temp_misc.sprites[sprFALL] = ;
6286 }
6287
6288
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 13)
6289 {
6290
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 36 times.
2340 for(size_t q = 0; q < 64; ++q)
6291 {
6292 2304 bottletype* bt = &(temp_misc.bottle_types[q]);
6293
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!pfread(bt->name, 32, f))
6294 return qe_invalid;
6295
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 2304 times.
9216 for(size_t j = 0; j < 3; ++j)
6296 {
6297
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_getc(&(bt->counter[j]), f))
6298 return qe_invalid;
6299
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_igetw(&(bt->amount[j]), f))
6300 return qe_invalid;
6301 6912 }
6302
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->flags), f))
6303 return qe_invalid;
6304
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->next_type), f))
6305 return qe_invalid;
6306 2304 }
6307
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(size_t q = 0; q < 256; ++q)
6308 {
6309 9216 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6310
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (!pfread(bst->name, 32, f))
6311 return qe_invalid;
6312
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 9216 times.
36864 for(size_t j = 0; j < 3; ++j)
6313 {
6314
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->fill[j]), f))
6315 return qe_invalid;
6316
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->comb[j]), f))
6317 return qe_invalid;
6318
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->cset[j]), f))
6319 return qe_invalid;
6320
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->price[j]), f))
6321 return qe_invalid;
6322
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->str[j]), f))
6323 return qe_invalid;
6324 27648 }
6325 9216 }
6326 36 }
6327 else
6328 {
6329
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6330 5696 temp_misc.bottle_types[q].clear();
6331
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6332 22784 temp_misc.bottle_shop_types[q].clear();
6333 }
6334
6335
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 14)
6336 {
6337 byte msfx;
6338
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sfxMAX; ++q)
6339 {
6340
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&msfx,f))
6341 return qe_invalid;
6342 9216 temp_misc.miscsfx[q] = msfx;
6343 9216 }
6344 36 }
6345 else
6346 {
6347 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6348 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6349 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6350 }
6351
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version < 15)
6352 {
6353 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6354 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6355 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6356 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6357 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6358 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6359 89 }
6360
6361 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6362
6363 125 return 0;
6364 129 }
6365
6366 extern char *item_string[MAXITEMS];
6367 extern const char *old_item_string[iLast];
6368 extern char *weapon_string[MAXWPNS];
6369 extern const char *old_weapon_string[wLast];
6370
6371 129 int32_t readitems(PACKFILE *f, word version, word build)
6372 {
6373 byte padding;
6374 int32_t dummy;
6375 129 word items_to_read=MAXITEMS;
6376 itemdata tempitem;
6377 129 word s_version=0, s_cversion=0;
6378 word dummy_word;
6379
6380
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(version < 0x186)
6381 {
6382 items_to_read=64;
6383 }
6384
6385
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
6386 {
6387 125 items_to_read=0;
6388
6389 //section version info
6390
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
6391 {
6392 return qe_invalid;
6393 }
6394
6395 125 FFCore.quest_format[vItems] = s_version;
6396
6397 //al_trace("Items version %d\n", s_version);
6398
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
6399 {
6400 return qe_invalid;
6401 }
6402
6403 //section size
6404
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
6405 {
6406 return qe_invalid;
6407 }
6408
6409 //finally... section data
6410
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&items_to_read,f))
6411 {
6412 return qe_invalid;
6413 }
6414
6415
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6416 {
6417 return qe_invalid;
6418 }
6419 125 }
6420
6421
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>1)
6422 {
6423
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<items_to_read; i++)
6424 {
6425 char tempname[64];
6426
6427
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
6428 {
6429 return qe_invalid;
6430 }
6431
6432 28928 item_string[i][0] = '\0';
6433 28928 strncat(item_string[i], tempname, 64 - 1);
6434 28928 }
6435 113 }
6436 else
6437 {
6438
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6439 {
6440 4096 reset_itemname(i);
6441 4096 }
6442 }
6443
6444
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
6445 {
6446 33024 itemdata& id = itemsbuf[i];
6447 33024 memset(&id, 0, sizeof(itemdata));
6448 33024 id.count=-1;
6449 33024 id.playsound=WAV_SCALE;
6450 33024 reset_itembuf(&id,i);
6451 33024 }
6452
6453
2/2
✓ Branch 0 taken 30792 times.
✓ Branch 1 taken 129 times.
30921 for(int32_t i=0; i<items_to_read; i++)
6454 {
6455 30792 memset(&tempitem, 0, sizeof(itemdata));
6456 30792 reset_itembuf(&tempitem,i);
6457
6458
6459
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21576 times.
30792 if ( s_version > 35 ) //expanded tiles
6460 {
6461
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tile,f))
6462 {
6463 return qe_invalid;
6464 }
6465 9216 }
6466 else
6467 {
6468
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6469 {
6470 return qe_invalid;
6471 }
6472 }
6473
6474
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.misc_flags,f))
6475 {
6476 return qe_invalid;
6477 }
6478
6479
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.csets,f))
6480 {
6481 return qe_invalid;
6482 }
6483
6484
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.frames,f))
6485 {
6486 return qe_invalid;
6487 }
6488
6489
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.speed,f))
6490 {
6491 return qe_invalid;
6492 }
6493
6494
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.delay,f))
6495 {
6496 return qe_invalid;
6497 }
6498
6499
2/2
✓ Branch 0 taken 29768 times.
✓ Branch 1 taken 1024 times.
30792 if(version < 0x193)
6500 {
6501
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6502 {
6503 return qe_invalid;
6504 }
6505
6506
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6507 {
6508
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6509 {
6510 case iShield:
6511 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6512 4 break;
6513
6514 case iMShield:
6515 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6516 4 break;
6517
6518 default:
6519 1016 tempitem.ltm=0;
6520 1016 break;
6521 }
6522
6523 1024 tempitem.count=-1;
6524 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6525 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6526 1024 tempitem.family=0xFF;
6527 1024 tempitem.playsound=WAV_SCALE;
6528 1024 reset_itembuf(&tempitem,i);
6529
6530 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6531
6532 1024 continue;
6533 }
6534 }
6535
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29768 times.
29768 if(!p_igetl(&tempitem.ltm,f))
6537 {
6538 return qe_invalid;
6539 }
6540
6541
1/2
✓ Branch 0 taken 29768 times.
✗ Branch 1 not taken.
29768 if(version < 0x193)
6542 {
6543 for(int32_t q=0; q<12; q++)
6544 {
6545 if(!p_getc(&padding,f))
6546 {
6547 return qe_invalid;
6548 }
6549 }
6550 }
6551
6552
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 840 times.
29768 if(s_version>1)
6553 {
6554
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if ( s_version >= 31 )
6555 {
6556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.family,f))
6557 {
6558 return qe_invalid;
6559 }
6560 9216 }
6561 else
6562 {
6563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6564 {
6565 return qe_invalid;
6566 }
6567 }
6568
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version < 16)
6569 if(tempitem.family == 0xFF)
6570 tempitem.family = itype_misc;
6571
6572
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.fam_type,f))
6573 {
6574 return qe_invalid;
6575 }
6576
6577
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6578 {
6579
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version>=31)
6580 {
6581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.power,f))
6582 {
6583 return qe_invalid;
6584 }
6585 9216 }
6586 else
6587 {
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6589 {
6590 return qe_invalid;
6591 }
6592 }
6593
6594 //converted flags from 16b to 32b -Z
6595
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version < 41 )
6596 {
6597
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6598 {
6599 return qe_invalid;
6600 }
6601 19712 }
6602 else
6603 {
6604
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.flags,f))
6605 {
6606 return qe_invalid;
6607 }
6608 }
6609 28928 }
6610 else
6611 {
6612 //tempitem.power = tempitem.fam_type;
6613 char tempchar;
6614
6615 if(!p_getc(&tempchar,f))
6616 {
6617 return qe_invalid;
6618 }
6619
6620 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6621 }
6622
6623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.script,f))
6624 {
6625 return qe_invalid;
6626 }
6627
6628
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6629 {
6630 if(tempitem.script > NUMSCRIPTITEM)
6631 {
6632 tempitem.script = 0;
6633 }
6634 }
6635
6636
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.count,f))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetw(&tempitem.amount,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.collect_script,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6652 {
6653 if(tempitem.collect_script > NUMSCRIPTITEM)
6654 {
6655 tempitem.collect_script = 0;
6656 }
6657 }
6658
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.setmax,f))
6660 {
6661 return qe_invalid;
6662 }
6663
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.max,f))
6665 {
6666 return qe_invalid;
6667 }
6668
6669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.playsound,f))
6670 {
6671 return qe_invalid;
6672 }
6673
6674
2/2
✓ Branch 0 taken 231424 times.
✓ Branch 1 taken 28928 times.
260352 for(int32_t j=0; j<8; j++)
6675 {
6676
1/2
✓ Branch 0 taken 231424 times.
✗ Branch 1 not taken.
231424 if(!p_igetl(&tempitem.initiald[j],f))
6677 {
6678 return qe_invalid;
6679 }
6680 231424 }
6681
6682
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 28928 times.
86784 for(int32_t j=0; j<2; j++)
6683 {
6684
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempitem.initiala[j],f))
6685 {
6686 return qe_invalid;
6687 }
6688 57856 }
6689
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>4)
6691 {
6692
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6693 {
6694
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn,f))
6695 {
6696 return qe_invalid;
6697 }
6698
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn2,f))
6700 {
6701 return qe_invalid;
6702 }
6703
6704
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn3,f))
6705 {
6706 return qe_invalid;
6707 }
6708
6709
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn4,f))
6710 {
6711 return qe_invalid;
6712 }
6713
6714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=15)
6715 {
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn5,f))
6717 {
6718 return qe_invalid;
6719 }
6720
6721
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn6,f))
6722 {
6723 return qe_invalid;
6724 }
6725
6726
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn7,f))
6727 {
6728 return qe_invalid;
6729 }
6730
6731
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn8,f))
6732 {
6733 return qe_invalid;
6734 }
6735
6736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn9,f))
6737 {
6738 return qe_invalid;
6739 }
6740
6741
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn10,f))
6742 {
6743 return qe_invalid;
6744 }
6745 28928 }
6746
6747
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.pickup_hearts,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6753 {
6754 if(!p_igetw(&dummy_word,f))
6755 {
6756 return qe_invalid;
6757 }
6758
6759 tempitem.misc1=dummy_word;
6760
6761 if(!p_igetw(&dummy_word,f))
6762 {
6763 return qe_invalid;
6764 }
6765
6766 tempitem.misc2=dummy_word;
6767 }
6768 else
6769 {
6770
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc1,f))
6771 {
6772 return qe_invalid;
6773 }
6774
6775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc2,f))
6776 {
6777 return qe_invalid;
6778 }
6779
6780 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6781
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<24)
6782 {
6783 if(tempitem.family==itype_shield)
6784 {
6785 tempitem.misc1|=shSCRIPT;
6786 }
6787 }
6788 }
6789
6790
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if(s_version < 53)
6791 {
6792 byte tempbyte;
6793
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6794 {
6795 return qe_invalid;
6796 }
6797 19712 tempitem.cost_amount[0] = tempbyte;
6798 19712 }
6799 else
6800 {
6801
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
6802 {
6803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetw(&tempitem.cost_amount[q],f))
6804 {
6805 return qe_invalid;
6806 }
6807 18432 }
6808 }
6809 28928 }
6810 else
6811 {
6812 char tempchar;
6813
6814 if(!p_getc(&tempchar,f))
6815 {
6816 return qe_invalid;
6817 }
6818
6819 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6820 }
6821
6822 // June 2007: more misc. attributes
6823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=12)
6824 {
6825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6826 {
6827 if(!p_igetw(&dummy_word,f))
6828 {
6829 return qe_invalid;
6830 }
6831
6832 tempitem.misc3=dummy_word;
6833
6834 if(!p_igetw(&dummy_word,f))
6835 {
6836 return qe_invalid;
6837 }
6838
6839 tempitem.misc4=dummy_word;
6840 }
6841 else
6842 {
6843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc3,f))
6844 {
6845 return qe_invalid;
6846 }
6847
6848
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc4,f))
6849 {
6850 return qe_invalid;
6851 }
6852
6853
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc5,f))
6854 {
6855 return qe_invalid;
6856 }
6857
6858
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc6,f))
6859 {
6860 return qe_invalid;
6861 }
6862
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc7,f))
6864 {
6865 return qe_invalid;
6866 }
6867
6868
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc8,f))
6869 {
6870 return qe_invalid;
6871 }
6872
6873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc9,f))
6874 {
6875 return qe_invalid;
6876 }
6877
6878
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc10,f))
6879 {
6880 return qe_invalid;
6881 }
6882 }
6883
6884
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.usesound,f))
6885 {
6886 return qe_invalid;
6887 }
6888
6889
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version >= 49)
6890 {
6891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usesound2,f))
6892 {
6893 return qe_invalid;
6894 }
6895 9216 }
6896 19712 else tempitem.usesound2 = 0;
6897
6898
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
28928 if(s_version < 50 && tempitem.family == itype_mirror)
6899 {
6900 //Split continue/dmap warp effect/sfx, port for old
6901 tempitem.misc2 = tempitem.misc1;
6902 tempitem.usesound2 = tempitem.usesound;
6903 }
6904 28928 }
6905 28928 }
6906
6907
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6908 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.useweapon,f))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usedefence,f))
6914 {
6915 return qe_invalid;
6916 }
6917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weaprange,f))
6918 {
6919 return qe_invalid;
6920 }
6921
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weapduration,f))
6922 {
6923 return qe_invalid;
6924 }
6925
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 9216 times.
101376 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6926 {
6927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_igetl(&tempitem.weap_pattern[q],f))
6928 {
6929 return qe_invalid;
6930 }
6931 92160 }
6932 9216 }
6933
6934
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6935 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6936
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.duplicates,f))
6937 {
6938 return qe_invalid;
6939 }
6940
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < INITIAL_D; q++ )
6941 {
6942
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 if(!p_igetl(&tempitem.weap_initiald[q],f))
6943 {
6944 return qe_invalid;
6945 }
6946 73728 }
6947
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < INITIAL_A; q++ )
6948 {
6949
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.weap_initiala[q],f))
6950 {
6951 return qe_invalid;
6952 }
6953 18432 }
6954
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.drawlayer,f))
6956 {
6957 return qe_invalid;
6958 }
6959
6960
6961
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxofs,f))
6962 {
6963 return qe_invalid;
6964 }
6965
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hyofs,f))
6966 {
6967 return qe_invalid;
6968 }
6969
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxsz,f))
6970 {
6971 return qe_invalid;
6972 }
6973
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hysz,f))
6974 {
6975 return qe_invalid;
6976 }
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.hzsz,f))
6978 {
6979 return qe_invalid;
6980 }
6981
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.xofs,f))
6982 {
6983 return qe_invalid;
6984 }
6985
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.yofs,f))
6986 {
6987 return qe_invalid;
6988 }
6989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxofs,f))
6990 {
6991 return qe_invalid;
6992 }
6993
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_hyofs,f))
6994 {
6995 return qe_invalid;
6996 }
6997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxsz,f))
6998 {
6999 return qe_invalid;
7000 }
7001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hysz,f))
7002 {
7003 return qe_invalid;
7004 }
7005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hzsz,f))
7006 {
7007 return qe_invalid;
7008 }
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_xofs,f))
7010 {
7011 return qe_invalid;
7012 }
7013
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_yofs,f))
7014 {
7015 return qe_invalid;
7016 }
7017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.weaponscript,f))
7018 {
7019 return qe_invalid;
7020 }
7021
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.wpnsprite,f))
7022 {
7023 return qe_invalid;
7024 }
7025 9216 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7026
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < num_cost_tmr; ++q)
7027 {
7028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7029 {
7030 return qe_invalid;
7031 }
7032 18432 }
7033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 for(auto q = num_cost_tmr; q < 2; ++q)
7034 tempitem.magiccosttimer[q] = 0;
7035 9216 }
7036
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7037 {
7038 //Item Size FLags, TileWidth, TileHeight
7039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.overrideFLAGS,f))
7040 {
7041 return qe_invalid;
7042 }
7043
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tilew,f))
7044 {
7045 return qe_invalid;
7046 }
7047
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tileh,f))
7048 {
7049 return qe_invalid;
7050 }
7051 9216 }
7052
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 29 ) //! More new vars.
7053 {
7054 //Item Size FLags, TileWidth, TileHeight
7055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7056 {
7057 return qe_invalid;
7058 }
7059
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tilew,f))
7060 {
7061 return qe_invalid;
7062 }
7063
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tileh,f))
7064 {
7065 return qe_invalid;
7066 }
7067 9216 }
7068
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 30 ) //! More new vars.
7069 {
7070 //Pickup Type
7071
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.pickup,f))
7072 {
7073 return qe_invalid;
7074 }
7075 9216 }
7076
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 32 ) //! More new vars.
7077 {
7078 //Pickup Type
7079
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.pstring,f))
7080 {
7081 return qe_invalid;
7082 }
7083 9216 }
7084
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 33 ) //! More new vars.
7085 {
7086 //Pickup Type
7087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.pickup_string_flags,f))
7088 {
7089 return qe_invalid;
7090 }
7091 9216 }
7092
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 34 ) //! cost counter
7093 {
7094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(s_version < 53)
7095 {
7096 if(!p_getc(&tempitem.cost_counter[0],f))
7097 {
7098 return qe_invalid;
7099 }
7100 }
7101 else
7102 {
7103
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
7104 {
7105
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.cost_counter[q],f))
7106 {
7107 return qe_invalid;
7108 }
7109 18432 }
7110 }
7111 9216 }
7112
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 44 ) //! sprite scripts
7113 {
7114
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < 8; q++ )
7115 {
7116
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7117 {
7118
1/2
✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
4792320 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7119 {
7120 return qe_invalid;
7121 }
7122 4792320 }
7123
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7124 {
7125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7126 {
7127 return qe_invalid;
7128 }
7129 4792320 }
7130
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7131 {
7132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7133 {
7134 return qe_invalid;
7135 }
7136 4792320 }
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7138 {
7139 return qe_invalid;
7140 }
7141
7142 73728 }
7143
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < 2; q++ )
7144 {
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7146 {
7147 return qe_invalid;
7148 }
7149 18432 }
7150 //Pickup Type
7151
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.sprite_script,f))
7152 {
7153 return qe_invalid;
7154 }
7155 9216 }
7156
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 48 ) //! pickup flags
7157 {
7158
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&(tempitem.pickupflag),f))
7159 {
7160 return qe_invalid;
7161 }
7162 9216 }
7163
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 7680 times.
28928 if ( s_version >= 57 )
7164 {
7165 7680 std::string str;
7166
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
✓ Branch 2 taken 7680 times.
✗ Branch 3 not taken.
7680 if(!p_getcstr(&str,f))
7167 return qe_invalid;
7168 7680 strncpy(tempitem.display_name,str.c_str(),255);
7169
1/3
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7680 }
7170 28928 }
7171 else
7172 {
7173 840 tempitem.count=-1;
7174 840 tempitem.family=itype_misc;
7175 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7176 840 tempitem.playsound=WAV_SCALE;
7177 840 reset_itembuf(&tempitem,i);
7178 }
7179
7180 29768 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7181 29768 }
7182
7183 //////////////////////////////////////////////////////
7184 // Now do any updates because of new item additions
7185 // (These can't be done above because items_to_read
7186 // might be too low.)
7187 //////////////////////////////////////////////////////
7188
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
7189 {
7190 33024 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7191
7192 //Account for older quests that didn't have an actual item for the used letter
7193
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 2 && i==iLetterUsed)
7194 {
7195 16 reset_itembuf(&tempitem, iLetterUsed);
7196 16 strcpy(item_string[i],old_item_string[i]);
7197 16 tempitem.tile = itemsbuf[iLetter].tile;
7198 16 tempitem.csets = itemsbuf[iLetter].csets;
7199 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7200 16 tempitem.frames = itemsbuf[iLetter].frames;
7201 16 tempitem.speed = itemsbuf[iLetter].speed;
7202 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7203 16 }
7204
7205
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 3)
7206 {
7207
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7208 {
7209 case iRocsFeather:
7210 case iHoverBoots:
7211 case iSpinScroll:
7212 case iL2SpinScroll:
7213 case iCrossScroll:
7214 case iQuakeScroll:
7215 case iL2QuakeScroll:
7216 case iWhispRing:
7217 case iL2WhispRing:
7218 case iChargeRing:
7219 case iL2ChargeRing:
7220 case iPerilScroll:
7221 case iWalletL3:
7222 case iQuiverL4:
7223 case iBombBagL4:
7224 case iBracelet:
7225 case iL2Bracelet:
7226 case iOldGlove:
7227 case iL2Ladder:
7228 case iWealthMedal:
7229 case iL2WealthMedal:
7230 case iL3WealthMedal:
7231 352 reset_itembuf(&tempitem, i);
7232 352 strcpy(item_string[i],old_item_string[i]);
7233 352 break;
7234
7235 case iSShield:
7236 16 reset_itembuf(&tempitem, i);
7237 16 strcpy(item_string[i],old_item_string[i]);
7238 16 strcpy(item_string[iShield],old_item_string[iShield]);
7239 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7240 16 break;
7241 }
7242 4096 }
7243
7244
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 5)
7245 {
7246
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7247 {
7248 case iHeartRing:
7249 case iL2HeartRing:
7250 case iL3HeartRing:
7251 case iMagicRing:
7252 case iL2MagicRing:
7253 case iL3MagicRing:
7254 case iL4MagicRing:
7255 112 reset_itembuf(&tempitem, i);
7256 112 strcpy(item_string[i],old_item_string[i]);
7257 112 break;
7258 }
7259 4096 }
7260
7261
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7262 {
7263
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7264 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7265
7266
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 64 times.
✓ Branch 23 taken 3376 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7267 {
7268 case iTriforce:
7269 16 tempitem.fam_type=1;
7270 16 break;
7271
7272 case iBigTri:
7273 16 tempitem.fam_type=0;
7274 16 break;
7275
7276 case iBombs:
7277 16 tempitem.fam_type=i_bomb;
7278 16 tempitem.power=4;
7279 16 tempitem.wpn=wBOMB;
7280 16 tempitem.wpn2=wBOOM;
7281 16 tempitem.misc1 = 50;
7282
7283
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7284
7285 16 break;
7286
7287 case iSBomb:
7288 16 tempitem.fam_type=i_sbomb;
7289 16 tempitem.power=16;
7290 16 tempitem.wpn=wSBOMB;
7291 16 tempitem.wpn2=wSBOOM;
7292 16 tempitem.misc1 = 50;
7293
7294
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7295
7296 16 break;
7297
7298 case iBook:
7299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7300 tempitem.wpn = wFIREMAGIC;
7301
7302 16 break;
7303
7304 case iSArrow:
7305 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7306 16 tempitem.power=4;
7307 16 tempitem.flags|=ITEM_GAMEDATA;
7308 16 tempitem.wpn=wSARROW;
7309 16 break;
7310
7311 case iGArrow:
7312 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7313 16 tempitem.power=8;
7314 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7315 16 tempitem.wpn=wGARROW;
7316 16 break;
7317
7318 case iBrang:
7319 16 tempitem.power=0;
7320 16 tempitem.wpn=wBRANG;
7321 16 tempitem.misc1=36;
7322 16 break;
7323
7324 case iMBrang:
7325 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7326 16 tempitem.power=0;
7327 16 tempitem.wpn=wMBRANG;
7328 16 break;
7329
7330 case iFBrang:
7331 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7332 16 tempitem.power=2;
7333 16 tempitem.wpn=wFBRANG;
7334 16 break;
7335
7336 case iBoots:
7337 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7338 16 tempitem.power=7;
7339 16 break;
7340
7341 case iWand:
7342 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7343 16 tempitem.power=2;
7344 16 tempitem.wpn=wWAND;
7345 16 tempitem.wpn3=wMAGIC;
7346 16 break;
7347
7348 case iBCandle:
7349 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7350 16 tempitem.power=1;
7351 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7352 16 tempitem.wpn3=wFIRE;
7353 16 break;
7354
7355 case iRCandle:
7356 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7357 16 tempitem.power=1;
7358 16 tempitem.wpn3=wFIRE;
7359 16 break;
7360
7361 case iSword:
7362 16 tempitem.power=1;
7363 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7364 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7365 16 tempitem.wpn2=wSWORDSLASH;
7366 16 break;
7367
7368 case iWSword:
7369 16 tempitem.power=2;
7370 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7371 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7372 16 tempitem.wpn2=wWSWORDSLASH;
7373 16 break;
7374
7375 case iMSword:
7376 16 tempitem.power=4;
7377 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7378 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7379 16 tempitem.wpn2=wMSWORDSLASH;
7380 16 break;
7381
7382 case iXSword:
7383 16 tempitem.power=8;
7384 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7385 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7386 16 tempitem.wpn2=wXSWORDSLASH;
7387 16 break;
7388
7389 case iDivineProtection:
7390 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7391 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7392 16 tempitem.wpn=wDIVINEPROTECTION1A;
7393 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7394 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7395 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7396 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7397 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7398 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7399 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7400 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7401 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7402 16 tempitem.misc1=512;
7403 16 tempitem.cost_amount[0]=64;
7404 16 break;
7405
7406 case iLens:
7407 16 tempitem.misc1=60;
7408 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7409 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7410 16 break;
7411
7412 case iArrow:
7413 16 tempitem.power=2;
7414 16 tempitem.wpn=wARROW;
7415 16 break;
7416
7417 case iHoverBoots:
7418 16 tempitem.misc1=45;
7419 16 tempitem.wpn=iwHover;
7420 16 break;
7421
7422 case iDivineFire:
7423 16 tempitem.power=8;
7424 16 tempitem.wpn=wDIVINEFIRE1A;
7425 16 tempitem.wpn2=wDIVINEFIRE1B;
7426 16 tempitem.wpn3=wDIVINEFIRES1A;
7427 16 tempitem.wpn4=wDIVINEFIRES1B;
7428 16 tempitem.misc1 = 32;
7429 16 tempitem.misc2 = 200;
7430 16 tempitem.cost_amount[0]=32;
7431 16 break;
7432
7433 case iDivineEscape:
7434 16 tempitem.cost_amount[0]=32;
7435 16 break;
7436
7437 case iHookshot:
7438 16 tempitem.power=0;
7439 16 tempitem.flags&=~ITEM_FLAG1;
7440 16 tempitem.wpn=wHSHEAD;
7441 16 tempitem.wpn2=wHSCHAIN_H;
7442 16 tempitem.wpn4=wHSHANDLE;
7443 16 tempitem.wpn3=wHSCHAIN_V;
7444 16 tempitem.misc1=50;
7445 16 tempitem.misc2=100;
7446 16 break;
7447
7448 case iLongshot:
7449 16 tempitem.power=0;
7450 16 tempitem.flags&=~ITEM_FLAG1;
7451 16 tempitem.wpn=wLSHEAD;
7452 16 tempitem.wpn2=wLSCHAIN_H;
7453 16 tempitem.wpn4=wLSHANDLE;
7454 16 tempitem.wpn3=wLSCHAIN_V;
7455 16 tempitem.misc1=99;
7456 16 tempitem.misc2=100;
7457 16 break;
7458
7459 case iHammer:
7460 16 tempitem.power=4;
7461 16 tempitem.wpn=wHAMMER;
7462 16 tempitem.wpn2=iwHammerSmack;
7463 16 break;
7464
7465 case iCByrna:
7466 16 tempitem.power=1;
7467 16 tempitem.wpn=wCBYRNA;
7468 16 tempitem.wpn2=wCBYRNASLASH;
7469 16 tempitem.wpn3=wCBYRNAORB;
7470 16 tempitem.misc1=4;
7471 16 tempitem.misc2=16;
7472 16 tempitem.misc3=1;
7473 16 tempitem.cost_amount[0]=1;
7474 16 break;
7475
7476 case iWhistle:
7477 16 tempitem.wpn=wWIND;
7478 16 tempitem.misc1=3;
7479 16 tempitem.flags|=ITEM_FLAG1;
7480 16 break;
7481
7482 case iBRing:
7483 16 tempitem.power=2;
7484 16 tempitem.misc1=spBLUE;
7485 16 break;
7486
7487 case iRRing:
7488 16 tempitem.power=4;
7489 16 tempitem.misc1=spRED;
7490 16 break;
7491
7492 case iGRing:
7493 16 tempitem.power=8;
7494 16 tempitem.misc1=spGOLD;
7495 16 break;
7496
7497 case iSpinScroll:
7498 16 tempitem.power = 2;
7499 16 tempitem.misc1 = 1;
7500 16 break;
7501
7502 case iL2SpinScroll:
7503 16 tempitem.family=itype_spinscroll2;
7504 16 tempitem.fam_type=1;
7505 16 tempitem.cost_amount[0]=8;
7506 16 tempitem.power=2;
7507 16 tempitem.misc1 = 20;
7508 16 break;
7509
7510 case iQuakeScroll:
7511 16 tempitem.misc1=0x10;
7512 16 tempitem.misc2=64;
7513 16 break;
7514
7515 case iL2QuakeScroll:
7516 16 tempitem.family=itype_quakescroll2;
7517 16 tempitem.fam_type=1;
7518 16 tempitem.power = 2;
7519 16 tempitem.misc1=0x20;
7520 16 tempitem.misc2=192;
7521 16 tempitem.cost_amount[0]=8;
7522 16 break;
7523
7524 case iChargeRing:
7525 16 tempitem.misc1=64;
7526 16 tempitem.misc2=128;
7527 16 break;
7528
7529 case iL2ChargeRing:
7530 16 tempitem.misc1=32;
7531 16 tempitem.misc2=64;
7532 16 break;
7533
7534 case iOldGlove:
7535 16 tempitem.flags |= ITEM_FLAG1;
7536
7537 //fallthrough
7538 case iBombBagL4:
7539 case iWalletL3:
7540 case iQuiverL4:
7541 case iBracelet:
7542 80 tempitem.power = 1;
7543 80 break;
7544
7545 case iL2Bracelet:
7546 16 tempitem.power = 2;
7547 16 break;
7548
7549 case iMKey:
7550 16 tempitem.power=0xFF;
7551 16 tempitem.flags |= ITEM_FLAG1;
7552 16 break;
7553 }
7554 4096 }
7555
7556
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 7)
7557 {
7558
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7559 {
7560 case iStoneAgony:
7561 case iStompBoots:
7562 case iPerilRing:
7563 case iWhimsicalRing:
7564 {
7565 64 reset_itembuf(&tempitem, i);
7566 64 strcpy(item_string[i],old_item_string[i]);
7567 64 break;
7568 }
7569 }
7570 4096 }
7571
7572
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 8) // May 2007: Some corrections.
7573 {
7574
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7575 {
7576 case iMShield:
7577 16 tempitem.misc1|=shFLAME;
7578 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7579
7580
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7581 {
7582 tempitem.misc2 |= shSWORD;
7583 }
7584
7585 // fallthrough
7586 case iShield:
7587 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7588
7589 // fallthrough
7590 case iSShield:
7591 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7592
7593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7594 {
7595 tempitem.misc2 |= shROCK;
7596 }
7597
7598 48 break;
7599
7600 case iWhispRing:
7601 16 tempitem.power=1;
7602 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7603 16 tempitem.misc1 = 3;
7604 16 break;
7605
7606 case iL2WhispRing:
7607 16 tempitem.power=0;
7608 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7609 16 tempitem.misc1 = 3;
7610 16 break;
7611
7612 case iL2Ladder:
7613 case iBow:
7614 case iCByrna:
7615 48 tempitem.power = 1;
7616 48 break;
7617 }
7618 4096 }
7619
7620
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 9 && i==iClock)
7621 {
7622 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7623 16 }
7624
7625 //add the misc flag for bomb
7626
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 10 && tempitem.family == itype_bomb)
7627 {
7628 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7629 16 }
7630
7631
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33024 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7632 {
7633 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7634 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7635 32 }
7636
7637
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 12) // June 2007: More Misc. attributes.
7638 {
7639
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7640 {
7641 case iFBrang:
7642 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7643
7644 //fallthrough
7645 case iMBrang:
7646 32 tempitem.misc3 |= shSWORD|shMAGIC;
7647
7648 //fallthrough
7649 case iHookshot:
7650 case iLongshot:
7651 //fallthrough
7652 64 tempitem.misc3 |= shFIREBALL;
7653
7654 case iBrang:
7655 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7656 80 break;
7657 }
7658
7659
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1740 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 64 times.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 1956 times.
4096 switch(tempitem.family)
7660 {
7661 case itype_hoverboots:
7662 16 tempitem.usesound = WAV_ZN1HOVER;
7663 16 break;
7664
7665 case itype_wand:
7666 16 tempitem.usesound = WAV_WAND;
7667 16 break;
7668
7669 case itype_book:
7670 16 tempitem.usesound = WAV_FIRE;
7671 16 break;
7672
7673 case itype_arrow:
7674 48 tempitem.usesound = WAV_ARROW;
7675 48 break;
7676
7677 case itype_hookshot:
7678 32 tempitem.usesound = WAV_HOOKSHOT;
7679 32 break;
7680
7681 case itype_brang:
7682 48 tempitem.usesound = WAV_BRANG;
7683 48 break;
7684
7685 case itype_shield:
7686 48 tempitem.usesound = WAV_CHINK;
7687 48 break;
7688
7689 case itype_sword:
7690 1740 tempitem.usesound = WAV_SWORD;
7691 1740 break;
7692
7693 case itype_whistle:
7694 16 tempitem.usesound = WAV_WHISTLE;
7695 16 break;
7696
7697 case itype_hammer:
7698 16 tempitem.usesound = WAV_HAMMER;
7699 16 break;
7700
7701 case itype_divinefire:
7702 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7703 16 break;
7704
7705 case itype_divineescape:
7706 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7707 16 break;
7708
7709 case itype_divineprotection:
7710 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7711 16 break;
7712
7713 case itype_bomb:
7714 case itype_sbomb:
7715 case itype_quakescroll:
7716 case itype_quakescroll2:
7717 64 tempitem.usesound = WAV_BOMB;
7718 64 break;
7719
7720 case itype_spinscroll:
7721 case itype_spinscroll2:
7722 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7723 32 break;
7724 }
7725 4096 }
7726
7727
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 13) // July 2007
7728 {
7729
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7730 {
7731 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7732 16 tempitem.power = 1;
7733 16 tempitem.flags|=ITEM_FLAG1;
7734 16 }
7735
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7736 16 tempitem.flags|=ITEM_FLAG1;
7737
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7738 {
7739 16 tempitem.flags|=ITEM_FLAG1;
7740 16 tempitem.power = 2;
7741 16 }
7742 4096 }
7743
7744
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 14) // August 2007
7745 {
7746
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7747 {
7748 32 tempitem.usesound = WAV_SCALE;
7749
7750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7751 32 tempitem.misc3=50;
7752 32 }
7753
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7754 {
7755 32 tempitem.flags |= ITEM_GAINOLD;
7756 32 }
7757 4096 }
7758
7759
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 17) // November 2007
7760 {
7761
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7762 {
7763 tempitem.wpn3 = wFIRE;
7764 }
7765
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7766 {
7767 16 tempitem.flags|=ITEM_FLAG1;
7768 16 }
7769 4096 }
7770
7771
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 18) // New Year's Eve 2007
7772 {
7773
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7774 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7775
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7776 16 tempitem.misc1 = 768; // Frames until it goes
7777
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7778 {
7779
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7780 {
7781 16 tempitem.misc2 = 1; // Cutscene 1
7782 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7783 16 }
7784 32 }
7785 4096 }
7786
7787
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 19) // January 2008
7788 {
7789
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7790 {
7791 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7792 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7793 16 }
7794 4096 }
7795
7796
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 20) // October 2008
7797 {
7798
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7799 {
7800 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7801 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7802 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7803 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7804 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7805 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7806 16 }
7807 4096 }
7808
7809
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 21) // November 2008
7810 {
7811
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7812 {
7813 tempitem.flags &= ~0x0100;
7814
7815 if(tempitem.family == itype_sword ||
7816 tempitem.family == itype_wand ||
7817 tempitem.family == itype_candle ||
7818 tempitem.family == itype_cbyrna)
7819 {
7820 tempitem.flags |= ITEM_FLAG4;
7821 }
7822 }
7823 4096 }
7824
7825
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 22) // September 2009
7826 {
7827
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7828 {
7829 32 tempitem.misc3 = tempitem.power/2;
7830 32 }
7831 4096 }
7832
7833
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 23) // March 2011
7834 {
7835
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7836 16 tempitem.wpn5 = wFIRE;
7837
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7838 16 tempitem.wpn2 = wFIRE;
7839 4096 }
7840
7841 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7842 // whether it was or not, and a lot of existing quests depended on the
7843 // incorrect behavior.
7844
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 25) // January 2012
7845 {
7846
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7847 64 tempitem.flags |= 16;
7848
7849
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7850 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7851 4096 }
7852
7853
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7854 {
7855
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7856 {
7857 case itype_sword:
7858 {
7859 7811 tempitem.flags &= ~(ITEM_FLAG5);
7860 7811 tempitem.misc3 = 0;
7861 7811 tempitem.misc4 = 0;
7862 7811 tempitem.misc5 = 0;
7863 7811 tempitem.misc6 = 0;
7864 7811 tempitem.misc7 = 0;
7865 7811 tempitem.misc8 = 0;
7866 7811 tempitem.misc9 = 0;
7867 7811 tempitem.misc10 = 0;
7868 7811 tempitem.wpn4 = 0;
7869 7811 tempitem.wpn5 = 0;
7870 7811 tempitem.wpn6 = 0;
7871 7811 tempitem.wpn7 = 0;
7872 7811 tempitem.wpn8 = 0;
7873 7811 tempitem.wpn9 = 0;
7874 7811 tempitem.wpn10 = 0;
7875 7811 break;
7876 }
7877 case itype_brang:
7878 {
7879 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7880 277 tempitem.misc2 = 0;
7881 277 tempitem.misc5 = 0;
7882 277 tempitem.misc6 = 0;
7883 277 tempitem.misc7 = 0;
7884 277 tempitem.misc8 = 0;
7885 277 tempitem.misc9 = 0;
7886 277 tempitem.misc10 = 0;
7887 277 tempitem.wpn4 = 0;
7888 277 tempitem.wpn5 = 0;
7889 277 tempitem.wpn6 = 0;
7890 277 tempitem.wpn7 = 0;
7891 277 tempitem.wpn8 = 0;
7892 277 tempitem.wpn9 = 0;
7893 277 tempitem.wpn10 = 0;
7894 277 break;
7895 }
7896 case itype_arrow:
7897 {
7898 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7899 274 tempitem.misc2 = 0;
7900 274 tempitem.misc3 = 0;
7901 274 tempitem.misc4 = 0;
7902 274 tempitem.misc5 = 0;
7903 274 tempitem.misc6 = 0;
7904 274 tempitem.misc7 = 0;
7905 274 tempitem.misc8 = 0;
7906 274 tempitem.misc9 = 0;
7907 274 tempitem.misc10 = 0;
7908 274 tempitem.wpn4 = 0;
7909 274 tempitem.wpn5 = 0;
7910 274 tempitem.wpn6 = 0;
7911 274 tempitem.wpn7 = 0;
7912 274 tempitem.wpn8 = 0;
7913 274 tempitem.wpn9 = 0;
7914 274 tempitem.wpn10 = 0;
7915 274 break;
7916 }
7917 case itype_candle:
7918 {
7919 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7920 222 tempitem.misc1 = 0;
7921 222 tempitem.misc2 = 0;
7922 222 tempitem.misc3 = 0;
7923 222 tempitem.misc4 = 0;
7924 222 tempitem.misc5 = 0;
7925 222 tempitem.misc6 = 0;
7926 222 tempitem.misc7 = 0;
7927 222 tempitem.misc8 = 0;
7928 222 tempitem.misc9 = 0;
7929 222 tempitem.misc10 = 0;
7930 222 tempitem.wpn4 = 0;
7931 222 tempitem.wpn5 = 0;
7932 222 tempitem.wpn6 = 0;
7933 222 tempitem.wpn7 = 0;
7934 222 tempitem.wpn8 = 0;
7935 222 tempitem.wpn9 = 0;
7936 222 tempitem.wpn10 = 0;
7937 222 break;
7938 }
7939 case itype_whistle:
7940 {
7941 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7942 138 tempitem.misc3 = 0;
7943 138 tempitem.misc4 = 0;
7944 138 tempitem.misc5 = 0;
7945 138 tempitem.misc6 = 0;
7946 138 tempitem.misc7 = 0;
7947 138 tempitem.misc8 = 0;
7948 138 tempitem.misc9 = 0;
7949 138 tempitem.misc10 = 0;
7950 138 tempitem.wpn2 = 0;
7951 138 tempitem.wpn3 = 0;
7952 138 tempitem.wpn4 = 0;
7953 138 tempitem.wpn5 = 0;
7954 138 tempitem.wpn6 = 0;
7955 138 tempitem.wpn7 = 0;
7956 138 tempitem.wpn8 = 0;
7957 138 tempitem.wpn9 = 0;
7958 138 tempitem.wpn10 = 0;
7959 138 break;
7960 }
7961 case itype_bait:
7962 {
7963 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7964 93 tempitem.misc2 = 0;
7965 93 tempitem.misc3 = 0;
7966 93 tempitem.misc4 = 0;
7967 93 tempitem.misc5 = 0;
7968 93 tempitem.misc6 = 0;
7969 93 tempitem.misc7 = 0;
7970 93 tempitem.misc8 = 0;
7971 93 tempitem.misc9 = 0;
7972 93 tempitem.misc10 = 0;
7973 93 tempitem.wpn2 = 0;
7974 93 tempitem.wpn3 = 0;
7975 93 tempitem.wpn4 = 0;
7976 93 tempitem.wpn5 = 0;
7977 93 tempitem.wpn6 = 0;
7978 93 tempitem.wpn7 = 0;
7979 93 tempitem.wpn8 = 0;
7980 93 tempitem.wpn9 = 0;
7981 93 tempitem.wpn10 = 0;
7982 93 break;
7983 }
7984 case itype_letter:
7985 {
7986 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7987 184 tempitem.misc1 = 0;
7988 184 tempitem.misc2 = 0;
7989 184 tempitem.misc3 = 0;
7990 184 tempitem.misc4 = 0;
7991 184 tempitem.misc5 = 0;
7992 184 tempitem.misc6 = 0;
7993 184 tempitem.misc7 = 0;
7994 184 tempitem.misc8 = 0;
7995 184 tempitem.misc9 = 0;
7996 184 tempitem.misc10 = 0;
7997 184 tempitem.wpn = 0;
7998 184 tempitem.wpn2 = 0;
7999 184 tempitem.wpn3 = 0;
8000 184 tempitem.wpn4 = 0;
8001 184 tempitem.wpn5 = 0;
8002 184 tempitem.wpn6 = 0;
8003 184 tempitem.wpn7 = 0;
8004 184 tempitem.wpn8 = 0;
8005 184 tempitem.wpn9 = 0;
8006 184 tempitem.wpn10 = 0;
8007 184 break;
8008 }
8009 case itype_potion:
8010 {
8011 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8012 183 tempitem.misc3 = 0;
8013 183 tempitem.misc4 = 0;
8014 183 tempitem.misc5 = 0;
8015 183 tempitem.misc6 = 0;
8016 183 tempitem.misc7 = 0;
8017 183 tempitem.misc8 = 0;
8018 183 tempitem.misc9 = 0;
8019 183 tempitem.misc10 = 0;
8020 183 tempitem.wpn = 0;
8021 183 tempitem.wpn2 = 0;
8022 183 tempitem.wpn3 = 0;
8023 183 tempitem.wpn4 = 0;
8024 183 tempitem.wpn5 = 0;
8025 183 tempitem.wpn6 = 0;
8026 183 tempitem.wpn7 = 0;
8027 183 tempitem.wpn8 = 0;
8028 183 tempitem.wpn9 = 0;
8029 183 tempitem.wpn10 = 0;
8030 183 break;
8031 }
8032 case itype_wand:
8033 {
8034 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8035 107 tempitem.misc1 = 0;
8036 107 tempitem.misc2 = 0;
8037 107 tempitem.misc3 = 0;
8038 107 tempitem.misc4 = 0;
8039 107 tempitem.misc5 = 0;
8040 107 tempitem.misc6 = 0;
8041 107 tempitem.misc7 = 0;
8042 107 tempitem.misc8 = 0;
8043 107 tempitem.misc9 = 0;
8044 107 tempitem.misc10 = 0;
8045 107 tempitem.wpn4 = 0;
8046 107 tempitem.wpn5 = 0;
8047 107 tempitem.wpn6 = 0;
8048 107 tempitem.wpn7 = 0;
8049 107 tempitem.wpn8 = 0;
8050 107 tempitem.wpn9 = 0;
8051 107 tempitem.wpn10 = 0;
8052 107 break;
8053 }
8054 case itype_ring:
8055 {
8056 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8057 302 tempitem.misc2 = 0;
8058 302 tempitem.misc3 = 0;
8059 302 tempitem.misc4 = 0;
8060 302 tempitem.misc5 = 0;
8061 302 tempitem.misc6 = 0;
8062 302 tempitem.misc7 = 0;
8063 302 tempitem.misc8 = 0;
8064 302 tempitem.misc9 = 0;
8065 302 tempitem.misc10 = 0;
8066 302 tempitem.wpn = 0;
8067 302 tempitem.wpn2 = 0;
8068 302 tempitem.wpn3 = 0;
8069 302 tempitem.wpn4 = 0;
8070 302 tempitem.wpn5 = 0;
8071 302 tempitem.wpn6 = 0;
8072 302 tempitem.wpn7 = 0;
8073 302 tempitem.wpn8 = 0;
8074 302 tempitem.wpn9 = 0;
8075 302 tempitem.wpn10 = 0;
8076 302 break;
8077 }
8078 case itype_wallet:
8079 {
8080 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8081 276 tempitem.misc3 = 0;
8082 276 tempitem.misc4 = 0;
8083 276 tempitem.misc5 = 0;
8084 276 tempitem.misc6 = 0;
8085 276 tempitem.misc7 = 0;
8086 276 tempitem.misc8 = 0;
8087 276 tempitem.misc9 = 0;
8088 276 tempitem.misc10 = 0;
8089 276 tempitem.wpn = 0;
8090 276 tempitem.wpn2 = 0;
8091 276 tempitem.wpn3 = 0;
8092 276 tempitem.wpn4 = 0;
8093 276 tempitem.wpn5 = 0;
8094 276 tempitem.wpn6 = 0;
8095 276 tempitem.wpn7 = 0;
8096 276 tempitem.wpn8 = 0;
8097 276 tempitem.wpn9 = 0;
8098 276 tempitem.wpn10 = 0;
8099 276 break;
8100 }
8101 case itype_amulet:
8102 {
8103 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8104 183 tempitem.misc1 = 0;
8105 183 tempitem.misc2 = 0;
8106 183 tempitem.misc3 = 0;
8107 183 tempitem.misc4 = 0;
8108 183 tempitem.misc5 = 0;
8109 183 tempitem.misc6 = 0;
8110 183 tempitem.misc7 = 0;
8111 183 tempitem.misc8 = 0;
8112 183 tempitem.misc9 = 0;
8113 183 tempitem.misc10 = 0;
8114 183 tempitem.wpn = 0;
8115 183 tempitem.wpn2 = 0;
8116 183 tempitem.wpn3 = 0;
8117 183 tempitem.wpn4 = 0;
8118 183 tempitem.wpn5 = 0;
8119 183 tempitem.wpn6 = 0;
8120 183 tempitem.wpn7 = 0;
8121 183 tempitem.wpn8 = 0;
8122 183 tempitem.wpn9 = 0;
8123 183 tempitem.wpn10 = 0;
8124 183 break;
8125 }
8126 case itype_shield:
8127 {
8128 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8129 283 tempitem.misc3 = 0;
8130 283 tempitem.misc4 = 0;
8131 283 tempitem.misc5 = 0;
8132 283 tempitem.misc6 = 0;
8133 283 tempitem.misc7 = 0;
8134 283 tempitem.misc8 = 0;
8135 283 tempitem.misc9 = 0;
8136 283 tempitem.misc10 = 0;
8137 283 tempitem.wpn = 0;
8138 283 tempitem.wpn2 = 0;
8139 283 tempitem.wpn3 = 0;
8140 283 tempitem.wpn4 = 0;
8141 283 tempitem.wpn5 = 0;
8142 283 tempitem.wpn6 = 0;
8143 283 tempitem.wpn7 = 0;
8144 283 tempitem.wpn8 = 0;
8145 283 tempitem.wpn9 = 0;
8146 283 tempitem.wpn10 = 0;
8147 283 break;
8148 }
8149 case itype_bow:
8150 {
8151 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8152 184 tempitem.misc1 = 0;
8153 184 tempitem.misc2 = 0;
8154 184 tempitem.misc3 = 0;
8155 184 tempitem.misc4 = 0;
8156 184 tempitem.misc5 = 0;
8157 184 tempitem.misc6 = 0;
8158 184 tempitem.misc7 = 0;
8159 184 tempitem.misc8 = 0;
8160 184 tempitem.misc9 = 0;
8161 184 tempitem.misc10 = 0;
8162 184 tempitem.wpn = 0;
8163 184 tempitem.wpn2 = 0;
8164 184 tempitem.wpn3 = 0;
8165 184 tempitem.wpn4 = 0;
8166 184 tempitem.wpn5 = 0;
8167 184 tempitem.wpn6 = 0;
8168 184 tempitem.wpn7 = 0;
8169 184 tempitem.wpn8 = 0;
8170 184 tempitem.wpn9 = 0;
8171 184 tempitem.wpn10 = 0;
8172 184 break;
8173 }
8174 case itype_raft:
8175 {
8176 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8177 92 tempitem.misc1 = 0;
8178 92 tempitem.misc2 = 0;
8179 92 tempitem.misc3 = 0;
8180 92 tempitem.misc4 = 0;
8181 92 tempitem.misc5 = 0;
8182 92 tempitem.misc6 = 0;
8183 92 tempitem.misc7 = 0;
8184 92 tempitem.misc8 = 0;
8185 92 tempitem.misc9 = 0;
8186 92 tempitem.misc10 = 0;
8187 92 tempitem.wpn = 0;
8188 92 tempitem.wpn2 = 0;
8189 92 tempitem.wpn3 = 0;
8190 92 tempitem.wpn4 = 0;
8191 92 tempitem.wpn5 = 0;
8192 92 tempitem.wpn6 = 0;
8193 92 tempitem.wpn7 = 0;
8194 92 tempitem.wpn8 = 0;
8195 92 tempitem.wpn9 = 0;
8196 92 tempitem.wpn10 = 0;
8197 92 break;
8198 }
8199 case itype_ladder:
8200 {
8201 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8202 184 tempitem.misc1 = 0;
8203 184 tempitem.misc2 = 0;
8204 184 tempitem.misc3 = 0;
8205 184 tempitem.misc4 = 0;
8206 184 tempitem.misc5 = 0;
8207 184 tempitem.misc6 = 0;
8208 184 tempitem.misc7 = 0;
8209 184 tempitem.misc8 = 0;
8210 184 tempitem.misc9 = 0;
8211 184 tempitem.misc10 = 0;
8212 184 tempitem.wpn = 0;
8213 184 tempitem.wpn2 = 0;
8214 184 tempitem.wpn3 = 0;
8215 184 tempitem.wpn4 = 0;
8216 184 tempitem.wpn5 = 0;
8217 184 tempitem.wpn6 = 0;
8218 184 tempitem.wpn7 = 0;
8219 184 tempitem.wpn8 = 0;
8220 184 tempitem.wpn9 = 0;
8221 184 tempitem.wpn10 = 0;
8222 184 break;
8223 }
8224 case itype_book:
8225 {
8226 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8227 107 tempitem.misc1 = 0;
8228 107 tempitem.misc2 = 0;
8229 107 tempitem.misc3 = 0;
8230 107 tempitem.misc4 = 0;
8231 107 tempitem.misc5 = 0;
8232 107 tempitem.misc6 = 0;
8233 107 tempitem.misc7 = 0;
8234 107 tempitem.misc8 = 0;
8235 107 tempitem.misc9 = 0;
8236 107 tempitem.misc10 = 0;
8237 107 tempitem.wpn3 = 0;
8238 107 tempitem.wpn4 = 0;
8239 107 tempitem.wpn5 = 0;
8240 107 tempitem.wpn6 = 0;
8241 107 tempitem.wpn7 = 0;
8242 107 tempitem.wpn8 = 0;
8243 107 tempitem.wpn9 = 0;
8244 107 tempitem.wpn10 = 0;
8245 107 break;
8246 }
8247 case itype_magickey:
8248 {
8249 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8250 92 tempitem.misc1 = 0;
8251 92 tempitem.misc2 = 0;
8252 92 tempitem.misc3 = 0;
8253 92 tempitem.misc4 = 0;
8254 92 tempitem.misc5 = 0;
8255 92 tempitem.misc6 = 0;
8256 92 tempitem.misc7 = 0;
8257 92 tempitem.misc8 = 0;
8258 92 tempitem.misc9 = 0;
8259 92 tempitem.misc10 = 0;
8260 92 tempitem.wpn = 0;
8261 92 tempitem.wpn2 = 0;
8262 92 tempitem.wpn3 = 0;
8263 92 tempitem.wpn4 = 0;
8264 92 tempitem.wpn5 = 0;
8265 92 tempitem.wpn6 = 0;
8266 92 tempitem.wpn7 = 0;
8267 92 tempitem.wpn8 = 0;
8268 92 tempitem.wpn9 = 0;
8269 92 tempitem.wpn10 = 0;
8270 92 break;
8271 }
8272 case itype_bracelet:
8273 {
8274 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8275 279 tempitem.misc1 = 0;
8276 279 tempitem.misc2 = 0;
8277 279 tempitem.misc3 = 0;
8278 279 tempitem.misc4 = 0;
8279 279 tempitem.misc5 = 0;
8280 279 tempitem.misc6 = 0;
8281 279 tempitem.misc7 = 0;
8282 279 tempitem.misc8 = 0;
8283 279 tempitem.misc9 = 0;
8284 279 tempitem.misc10 = 0;
8285 279 tempitem.wpn = 0;
8286 279 tempitem.wpn2 = 0;
8287 279 tempitem.wpn3 = 0;
8288 279 tempitem.wpn4 = 0;
8289 279 tempitem.wpn5 = 0;
8290 279 tempitem.wpn6 = 0;
8291 279 tempitem.wpn7 = 0;
8292 279 tempitem.wpn8 = 0;
8293 279 tempitem.wpn9 = 0;
8294 279 tempitem.wpn10 = 0;
8295 279 break;
8296 }
8297 case itype_flippers:
8298 {
8299 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8300 93 tempitem.misc1 = 0;
8301 93 tempitem.misc2 = 0;
8302 93 tempitem.misc3 = 0;
8303 93 tempitem.misc4 = 0;
8304 93 tempitem.misc5 = 0;
8305 93 tempitem.misc6 = 0;
8306 93 tempitem.misc7 = 0;
8307 93 tempitem.misc8 = 0;
8308 93 tempitem.misc9 = 0;
8309 93 tempitem.misc10 = 0;
8310 93 tempitem.wpn = 0;
8311 93 tempitem.wpn2 = 0;
8312 93 tempitem.wpn3 = 0;
8313 93 tempitem.wpn4 = 0;
8314 93 tempitem.wpn5 = 0;
8315 93 tempitem.wpn6 = 0;
8316 93 tempitem.wpn7 = 0;
8317 93 tempitem.wpn8 = 0;
8318 93 tempitem.wpn9 = 0;
8319 93 tempitem.wpn10 = 0;
8320 93 break;
8321 }
8322 case itype_boots:
8323 {
8324 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8325 94 tempitem.misc1 = 0;
8326 94 tempitem.misc2 = 0;
8327 94 tempitem.misc3 = 0;
8328 94 tempitem.misc4 = 0;
8329 94 tempitem.misc5 = 0;
8330 94 tempitem.misc6 = 0;
8331 94 tempitem.misc7 = 0;
8332 94 tempitem.misc8 = 0;
8333 94 tempitem.misc9 = 0;
8334 94 tempitem.misc10 = 0;
8335 94 tempitem.wpn = 0;
8336 94 tempitem.wpn2 = 0;
8337 94 tempitem.wpn3 = 0;
8338 94 tempitem.wpn4 = 0;
8339 94 tempitem.wpn5 = 0;
8340 94 tempitem.wpn6 = 0;
8341 94 tempitem.wpn7 = 0;
8342 94 tempitem.wpn8 = 0;
8343 94 tempitem.wpn9 = 0;
8344 94 tempitem.wpn10 = 0;
8345 94 break;
8346 }
8347 case itype_hookshot:
8348 {
8349 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8350 184 tempitem.misc5 = 0;
8351 184 tempitem.misc6 = 0;
8352 184 tempitem.misc7 = 0;
8353 184 tempitem.misc8 = 0;
8354 184 tempitem.misc9 = 0;
8355 184 tempitem.misc10 = 0;
8356 184 tempitem.wpn5 = 0;
8357 184 tempitem.wpn6 = 0;
8358 184 tempitem.wpn7 = 0;
8359 184 tempitem.wpn8 = 0;
8360 184 tempitem.wpn9 = 0;
8361 184 tempitem.wpn10 = 0;
8362 184 break;
8363 }
8364 case itype_lens:
8365 {
8366 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8367 92 tempitem.misc2 = 0;
8368 92 tempitem.misc3 = 0;
8369 92 tempitem.misc4 = 0;
8370 92 tempitem.misc5 = 0;
8371 92 tempitem.misc6 = 0;
8372 92 tempitem.misc7 = 0;
8373 92 tempitem.misc8 = 0;
8374 92 tempitem.misc9 = 0;
8375 92 tempitem.misc10 = 0;
8376 92 tempitem.wpn = 0;
8377 92 tempitem.wpn2 = 0;
8378 92 tempitem.wpn3 = 0;
8379 92 tempitem.wpn4 = 0;
8380 92 tempitem.wpn5 = 0;
8381 92 tempitem.wpn6 = 0;
8382 92 tempitem.wpn7 = 0;
8383 92 tempitem.wpn8 = 0;
8384 92 tempitem.wpn9 = 0;
8385 92 tempitem.wpn10 = 0;
8386 92 break;
8387 }
8388 case itype_hammer:
8389 {
8390 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8391 93 tempitem.misc1 = 0;
8392 93 tempitem.misc2 = 0;
8393 93 tempitem.misc3 = 0;
8394 93 tempitem.misc4 = 0;
8395 93 tempitem.misc5 = 0;
8396 93 tempitem.misc6 = 0;
8397 93 tempitem.misc7 = 0;
8398 93 tempitem.misc8 = 0;
8399 93 tempitem.misc9 = 0;
8400 93 tempitem.misc10 = 0;
8401 93 tempitem.wpn3 = 0;
8402 93 tempitem.wpn4 = 0;
8403 93 tempitem.wpn5 = 0;
8404 93 tempitem.wpn6 = 0;
8405 93 tempitem.wpn7 = 0;
8406 93 tempitem.wpn8 = 0;
8407 93 tempitem.wpn9 = 0;
8408 93 tempitem.wpn10 = 0;
8409 93 break;
8410 }
8411 case itype_divinefire:
8412 {
8413 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8414 92 tempitem.misc3 = 0;
8415 92 tempitem.misc4 = 0;
8416 92 tempitem.misc5 = 0;
8417 92 tempitem.misc6 = 0;
8418 92 tempitem.misc7 = 0;
8419 92 tempitem.misc8 = 0;
8420 92 tempitem.misc9 = 0;
8421 92 tempitem.misc10 = 0;
8422 92 tempitem.wpn6 = 0;
8423 92 tempitem.wpn7 = 0;
8424 92 tempitem.wpn8 = 0;
8425 92 tempitem.wpn9 = 0;
8426 92 tempitem.wpn10 = 0;
8427 92 break;
8428 }
8429 case itype_divineescape:
8430 {
8431 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8432 92 tempitem.misc2 = 0;
8433 92 tempitem.misc3 = 0;
8434 92 tempitem.misc4 = 0;
8435 92 tempitem.misc5 = 0;
8436 92 tempitem.misc6 = 0;
8437 92 tempitem.misc7 = 0;
8438 92 tempitem.misc8 = 0;
8439 92 tempitem.misc9 = 0;
8440 92 tempitem.misc10 = 0;
8441 92 tempitem.wpn = 0;
8442 92 tempitem.wpn2 = 0;
8443 92 tempitem.wpn3 = 0;
8444 92 tempitem.wpn4 = 0;
8445 92 tempitem.wpn5 = 0;
8446 92 tempitem.wpn6 = 0;
8447 92 tempitem.wpn7 = 0;
8448 92 tempitem.wpn8 = 0;
8449 92 tempitem.wpn9 = 0;
8450 92 tempitem.wpn10 = 0;
8451 92 break;
8452 }
8453 case itype_divineprotection:
8454 {
8455 92 tempitem.flags &= ~ (ITEM_FLAG5);
8456 92 tempitem.misc2 = 0;
8457 92 tempitem.misc3 = 0;
8458 92 tempitem.misc4 = 0;
8459 92 tempitem.misc5 = 0;
8460 92 tempitem.misc6 = 0;
8461 92 tempitem.misc7 = 0;
8462 92 tempitem.misc8 = 0;
8463 92 tempitem.misc9 = 0;
8464 92 tempitem.misc10 = 0;
8465 92 break;
8466 }
8467 case itype_bomb:
8468 {
8469 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8470 107 tempitem.misc4 = 0;
8471 107 tempitem.misc5 = 0;
8472 107 tempitem.misc6 = 0;
8473 107 tempitem.misc7 = 0;
8474 107 tempitem.misc8 = 0;
8475 107 tempitem.misc9 = 0;
8476 107 tempitem.misc10 = 0;
8477 107 tempitem.wpn3 = 0;
8478 107 tempitem.wpn4 = 0;
8479 107 tempitem.wpn5 = 0;
8480 107 tempitem.wpn6 = 0;
8481 107 tempitem.wpn7 = 0;
8482 107 tempitem.wpn8 = 0;
8483 107 tempitem.wpn9 = 0;
8484 107 tempitem.wpn10 = 0;
8485 107 break;
8486 }
8487 case itype_sbomb:
8488 {
8489 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8490 92 tempitem.misc4 = 0;
8491 92 tempitem.misc5 = 0;
8492 92 tempitem.misc6 = 0;
8493 92 tempitem.misc7 = 0;
8494 92 tempitem.misc8 = 0;
8495 92 tempitem.misc9 = 0;
8496 92 tempitem.misc10 = 0;
8497 92 tempitem.wpn3 = 0;
8498 92 tempitem.wpn4 = 0;
8499 92 tempitem.wpn5 = 0;
8500 92 tempitem.wpn6 = 0;
8501 92 tempitem.wpn7 = 0;
8502 92 tempitem.wpn8 = 0;
8503 92 tempitem.wpn9 = 0;
8504 92 tempitem.wpn10 = 0;
8505 92 break;
8506 }
8507 case itype_clock:
8508 {
8509 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8510 93 tempitem.misc2 = 0;
8511 93 tempitem.misc3 = 0;
8512 93 tempitem.misc4 = 0;
8513 93 tempitem.misc5 = 0;
8514 93 tempitem.misc6 = 0;
8515 93 tempitem.misc7 = 0;
8516 93 tempitem.misc8 = 0;
8517 93 tempitem.misc9 = 0;
8518 93 tempitem.misc10 = 0;
8519 93 tempitem.wpn = 0;
8520 93 tempitem.wpn2 = 0;
8521 93 tempitem.wpn3 = 0;
8522 93 tempitem.wpn4 = 0;
8523 93 tempitem.wpn5 = 0;
8524 93 tempitem.wpn6 = 0;
8525 93 tempitem.wpn7 = 0;
8526 93 tempitem.wpn8 = 0;
8527 93 tempitem.wpn9 = 0;
8528 93 tempitem.wpn10 = 0;
8529 93 break;
8530 }
8531 case itype_key:
8532 {
8533 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8534 92 tempitem.misc1 = 0;
8535 92 tempitem.misc2 = 0;
8536 92 tempitem.misc3 = 0;
8537 92 tempitem.misc4 = 0;
8538 92 tempitem.misc5 = 0;
8539 92 tempitem.misc6 = 0;
8540 92 tempitem.misc7 = 0;
8541 92 tempitem.misc8 = 0;
8542 92 tempitem.misc9 = 0;
8543 92 tempitem.misc10 = 0;
8544 92 tempitem.wpn = 0;
8545 92 tempitem.wpn2 = 0;
8546 92 tempitem.wpn3 = 0;
8547 92 tempitem.wpn4 = 0;
8548 92 tempitem.wpn5 = 0;
8549 92 tempitem.wpn6 = 0;
8550 92 tempitem.wpn7 = 0;
8551 92 tempitem.wpn8 = 0;
8552 92 tempitem.wpn9 = 0;
8553 92 tempitem.wpn10 = 0;
8554 92 break;
8555 }
8556 case itype_magiccontainer:
8557 {
8558 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8559 93 tempitem.misc1 = 0;
8560 93 tempitem.misc2 = 0;
8561 93 tempitem.misc3 = 0;
8562 93 tempitem.misc4 = 0;
8563 93 tempitem.misc5 = 0;
8564 93 tempitem.misc6 = 0;
8565 93 tempitem.misc7 = 0;
8566 93 tempitem.misc8 = 0;
8567 93 tempitem.misc9 = 0;
8568 93 tempitem.misc10 = 0;
8569 93 tempitem.wpn = 0;
8570 93 tempitem.wpn2 = 0;
8571 93 tempitem.wpn3 = 0;
8572 93 tempitem.wpn4 = 0;
8573 93 tempitem.wpn5 = 0;
8574 93 tempitem.wpn6 = 0;
8575 93 tempitem.wpn7 = 0;
8576 93 tempitem.wpn8 = 0;
8577 93 tempitem.wpn9 = 0;
8578 93 tempitem.wpn10 = 0;
8579 93 break;
8580 }
8581 case itype_triforcepiece:
8582 {
8583 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8584 184 tempitem.misc3 = 0;
8585 184 tempitem.misc4 = 0;
8586 184 tempitem.misc5 = 0;
8587 184 tempitem.misc6 = 0;
8588 184 tempitem.misc7 = 0;
8589 184 tempitem.misc8 = 0;
8590 184 tempitem.misc9 = 0;
8591 184 tempitem.misc10 = 0;
8592 184 tempitem.wpn = 0;
8593 184 tempitem.wpn2 = 0;
8594 184 tempitem.wpn3 = 0;
8595 184 tempitem.wpn4 = 0;
8596 184 tempitem.wpn5 = 0;
8597 184 tempitem.wpn6 = 0;
8598 184 tempitem.wpn7 = 0;
8599 184 tempitem.wpn8 = 0;
8600 184 tempitem.wpn9 = 0;
8601 184 tempitem.wpn10 = 0;
8602 184 break;
8603 }
8604 case itype_map: case itype_compass: case itype_bosskey:
8605 {
8606 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8607 277 tempitem.misc1 = 0;
8608 277 tempitem.misc2 = 0;
8609 277 tempitem.misc3 = 0;
8610 277 tempitem.misc4 = 0;
8611 277 tempitem.misc5 = 0;
8612 277 tempitem.misc6 = 0;
8613 277 tempitem.misc7 = 0;
8614 277 tempitem.misc8 = 0;
8615 277 tempitem.misc9 = 0;
8616 277 tempitem.misc10 = 0;
8617 277 tempitem.wpn = 0;
8618 277 tempitem.wpn2 = 0;
8619 277 tempitem.wpn3 = 0;
8620 277 tempitem.wpn4 = 0;
8621 277 tempitem.wpn5 = 0;
8622 277 tempitem.wpn6 = 0;
8623 277 tempitem.wpn7 = 0;
8624 277 tempitem.wpn8 = 0;
8625 277 tempitem.wpn9 = 0;
8626 277 tempitem.wpn10 = 0;
8627 277 break;
8628 }
8629 case itype_quiver:
8630 {
8631 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8632 368 tempitem.misc3 = 0;
8633 368 tempitem.misc4 = 0;
8634 368 tempitem.misc5 = 0;
8635 368 tempitem.misc6 = 0;
8636 368 tempitem.misc7 = 0;
8637 368 tempitem.misc8 = 0;
8638 368 tempitem.misc9 = 0;
8639 368 tempitem.misc10 = 0;
8640 368 tempitem.wpn = 0;
8641 368 tempitem.wpn2 = 0;
8642 368 tempitem.wpn3 = 0;
8643 368 tempitem.wpn4 = 0;
8644 368 tempitem.wpn5 = 0;
8645 368 tempitem.wpn6 = 0;
8646 368 tempitem.wpn7 = 0;
8647 368 tempitem.wpn8 = 0;
8648 368 tempitem.wpn9 = 0;
8649 368 tempitem.wpn10 = 0;
8650 368 break;
8651 }
8652 case itype_lkey:
8653 {
8654 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8655 94 tempitem.misc1 = 0;
8656 94 tempitem.misc2 = 0;
8657 94 tempitem.misc3 = 0;
8658 94 tempitem.misc4 = 0;
8659 94 tempitem.misc5 = 0;
8660 94 tempitem.misc6 = 0;
8661 94 tempitem.misc7 = 0;
8662 94 tempitem.misc8 = 0;
8663 94 tempitem.misc9 = 0;
8664 94 tempitem.misc10 = 0;
8665 94 tempitem.wpn = 0;
8666 94 tempitem.wpn2 = 0;
8667 94 tempitem.wpn3 = 0;
8668 94 tempitem.wpn4 = 0;
8669 94 tempitem.wpn5 = 0;
8670 94 tempitem.wpn6 = 0;
8671 94 tempitem.wpn7 = 0;
8672 94 tempitem.wpn8 = 0;
8673 94 tempitem.wpn9 = 0;
8674 94 tempitem.wpn10 = 0;
8675 94 break;
8676 }
8677 case itype_cbyrna:
8678 {
8679 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8680 92 tempitem.misc4 = 0;
8681 92 tempitem.misc5 = 0;
8682 92 tempitem.misc6 = 0;
8683 92 tempitem.misc7 = 0;
8684 92 tempitem.misc8 = 0;
8685 92 tempitem.misc9 = 0;
8686 92 tempitem.misc10 = 0;
8687 92 tempitem.wpn6 = 0;
8688 92 tempitem.wpn7 = 0;
8689 92 tempitem.wpn8 = 0;
8690 92 tempitem.wpn9 = 0;
8691 92 tempitem.wpn10 = 0;
8692 92 break;
8693 }
8694 case itype_rupee: case itype_arrowammo:
8695 {
8696 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8697 1135 tempitem.misc1 = 0;
8698 1135 tempitem.misc2 = 0;
8699 1135 tempitem.misc3 = 0;
8700 1135 tempitem.misc4 = 0;
8701 1135 tempitem.misc5 = 0;
8702 1135 tempitem.misc6 = 0;
8703 1135 tempitem.misc7 = 0;
8704 1135 tempitem.misc8 = 0;
8705 1135 tempitem.misc9 = 0;
8706 1135 tempitem.misc10 = 0;
8707 1135 tempitem.wpn = 0;
8708 1135 tempitem.wpn2 = 0;
8709 1135 tempitem.wpn3 = 0;
8710 1135 tempitem.wpn4 = 0;
8711 1135 tempitem.wpn5 = 0;
8712 1135 tempitem.wpn6 = 0;
8713 1135 tempitem.wpn7 = 0;
8714 1135 tempitem.wpn8 = 0;
8715 1135 tempitem.wpn9 = 0;
8716 1135 tempitem.wpn10 = 0;
8717 1135 break;
8718 }
8719 case itype_fairy:
8720 {
8721 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8722 168 tempitem.misc4 = 0;
8723 168 tempitem.misc5 = 0;
8724 168 tempitem.misc6 = 0;
8725 168 tempitem.misc7 = 0;
8726 168 tempitem.misc8 = 0;
8727 168 tempitem.misc9 = 0;
8728 168 tempitem.misc10 = 0;
8729 168 tempitem.wpn = 0;
8730 168 tempitem.wpn2 = 0;
8731 168 tempitem.wpn3 = 0;
8732 168 tempitem.wpn4 = 0;
8733 168 tempitem.wpn5 = 0;
8734 168 tempitem.wpn6 = 0;
8735 168 tempitem.wpn7 = 0;
8736 168 tempitem.wpn8 = 0;
8737 168 tempitem.wpn9 = 0;
8738 168 tempitem.wpn10 = 0;
8739 168 break;
8740 }
8741 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8742 {
8743 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8744 983 tempitem.misc1 = 0;
8745 983 tempitem.misc2 = 0;
8746 983 tempitem.misc3 = 0;
8747 983 tempitem.misc4 = 0;
8748 983 tempitem.misc5 = 0;
8749 983 tempitem.misc6 = 0;
8750 983 tempitem.misc7 = 0;
8751 983 tempitem.misc8 = 0;
8752 983 tempitem.misc9 = 0;
8753 983 tempitem.misc10 = 0;
8754 983 tempitem.wpn = 0;
8755 983 tempitem.wpn2 = 0;
8756 983 tempitem.wpn3 = 0;
8757 983 tempitem.wpn4 = 0;
8758 983 tempitem.wpn5 = 0;
8759 983 tempitem.wpn6 = 0;
8760 983 tempitem.wpn7 = 0;
8761 983 tempitem.wpn8 = 0;
8762 983 tempitem.wpn9 = 0;
8763 983 tempitem.wpn10 = 0;
8764 983 break;
8765 }
8766 case itype_bombbag:
8767 {
8768 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8769 368 tempitem.misc3 = 0;
8770 368 tempitem.misc4 = 0;
8771 368 tempitem.misc5 = 0;
8772 368 tempitem.misc6 = 0;
8773 368 tempitem.misc7 = 0;
8774 368 tempitem.misc8 = 0;
8775 368 tempitem.misc9 = 0;
8776 368 tempitem.misc10 = 0;
8777 368 tempitem.wpn = 0;
8778 368 tempitem.wpn2 = 0;
8779 368 tempitem.wpn3 = 0;
8780 368 tempitem.wpn4 = 0;
8781 368 tempitem.wpn5 = 0;
8782 368 tempitem.wpn6 = 0;
8783 368 tempitem.wpn7 = 0;
8784 368 tempitem.wpn8 = 0;
8785 368 tempitem.wpn9 = 0;
8786 368 tempitem.wpn10 = 0;
8787 368 break;
8788 }
8789 case itype_rocs:
8790 {
8791 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8792 92 tempitem.misc1 = 0;
8793 92 tempitem.misc2 = 0;
8794 92 tempitem.misc3 = 0;
8795 92 tempitem.misc4 = 0;
8796 92 tempitem.misc5 = 0;
8797 92 tempitem.misc6 = 0;
8798 92 tempitem.misc7 = 0;
8799 92 tempitem.misc8 = 0;
8800 92 tempitem.misc9 = 0;
8801 92 tempitem.misc10 = 0;
8802 92 tempitem.wpn = 0;
8803 92 tempitem.wpn2 = 0;
8804 92 tempitem.wpn3 = 0;
8805 92 tempitem.wpn4 = 0;
8806 92 tempitem.wpn5 = 0;
8807 92 tempitem.wpn6 = 0;
8808 92 tempitem.wpn7 = 0;
8809 92 tempitem.wpn8 = 0;
8810 92 tempitem.wpn9 = 0;
8811 92 tempitem.wpn10 = 0;
8812 92 break;
8813 }
8814 case itype_hoverboots:
8815 {
8816 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8817 92 tempitem.misc2 = 0;
8818 92 tempitem.misc3 = 0;
8819 92 tempitem.misc4 = 0;
8820 92 tempitem.misc5 = 0;
8821 92 tempitem.misc6 = 0;
8822 92 tempitem.misc7 = 0;
8823 92 tempitem.misc8 = 0;
8824 92 tempitem.misc9 = 0;
8825 92 tempitem.misc10 = 0;
8826 92 tempitem.wpn2 = 0;
8827 92 tempitem.wpn3 = 0;
8828 92 tempitem.wpn4 = 0;
8829 92 tempitem.wpn5 = 0;
8830 92 tempitem.wpn6 = 0;
8831 92 tempitem.wpn7 = 0;
8832 92 tempitem.wpn8 = 0;
8833 92 tempitem.wpn9 = 0;
8834 92 tempitem.wpn10 = 0;
8835 92 break;
8836 }
8837 case itype_spinscroll:
8838 {
8839 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8840 92 tempitem.misc2 = 0;
8841 92 tempitem.misc3 = 0;
8842 92 tempitem.misc4 = 0;
8843 92 tempitem.misc5 = 0;
8844 92 tempitem.misc6 = 0;
8845 92 tempitem.misc7 = 0;
8846 92 tempitem.misc8 = 0;
8847 92 tempitem.misc9 = 0;
8848 92 tempitem.misc10 = 0;
8849 92 tempitem.wpn = 0;
8850 92 tempitem.wpn2 = 0;
8851 92 tempitem.wpn3 = 0;
8852 92 tempitem.wpn4 = 0;
8853 92 tempitem.wpn5 = 0;
8854 92 tempitem.wpn6 = 0;
8855 92 tempitem.wpn7 = 0;
8856 92 tempitem.wpn8 = 0;
8857 92 tempitem.wpn9 = 0;
8858 92 tempitem.wpn10 = 0;
8859 92 break;
8860 }
8861 case itype_crossscroll:
8862 {
8863 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8864 92 tempitem.misc1 = 0;
8865 92 tempitem.misc2 = 0;
8866 92 tempitem.misc3 = 0;
8867 92 tempitem.misc4 = 0;
8868 92 tempitem.misc5 = 0;
8869 92 tempitem.misc6 = 0;
8870 92 tempitem.misc7 = 0;
8871 92 tempitem.misc8 = 0;
8872 92 tempitem.misc9 = 0;
8873 92 tempitem.misc10 = 0;
8874 92 tempitem.wpn = 0;
8875 92 tempitem.wpn2 = 0;
8876 92 tempitem.wpn3 = 0;
8877 92 tempitem.wpn4 = 0;
8878 92 tempitem.wpn5 = 0;
8879 92 tempitem.wpn6 = 0;
8880 92 tempitem.wpn7 = 0;
8881 92 tempitem.wpn8 = 0;
8882 92 tempitem.wpn9 = 0;
8883 92 tempitem.wpn10 = 0;
8884 92 break;
8885 }
8886 case itype_quakescroll:
8887 {
8888 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8889 92 tempitem.misc3 = 0;
8890 92 tempitem.misc4 = 0;
8891 92 tempitem.misc5 = 0;
8892 92 tempitem.misc6 = 0;
8893 92 tempitem.misc7 = 0;
8894 92 tempitem.misc8 = 0;
8895 92 tempitem.misc9 = 0;
8896 92 tempitem.misc10 = 0;
8897 92 tempitem.wpn = 0;
8898 92 tempitem.wpn2 = 0;
8899 92 tempitem.wpn3 = 0;
8900 92 tempitem.wpn4 = 0;
8901 92 tempitem.wpn5 = 0;
8902 92 tempitem.wpn6 = 0;
8903 92 tempitem.wpn7 = 0;
8904 92 tempitem.wpn8 = 0;
8905 92 tempitem.wpn9 = 0;
8906 92 tempitem.wpn10 = 0;
8907 92 break;
8908 }
8909 case itype_whispring:
8910 {
8911 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8912 185 tempitem.misc2 = 0;
8913 185 tempitem.misc3 = 0;
8914 185 tempitem.misc4 = 0;
8915 185 tempitem.misc5 = 0;
8916 185 tempitem.misc6 = 0;
8917 185 tempitem.misc7 = 0;
8918 185 tempitem.misc8 = 0;
8919 185 tempitem.misc9 = 0;
8920 185 tempitem.misc10 = 0;
8921 185 tempitem.wpn = 0;
8922 185 tempitem.wpn2 = 0;
8923 185 tempitem.wpn3 = 0;
8924 185 tempitem.wpn4 = 0;
8925 185 tempitem.wpn5 = 0;
8926 185 tempitem.wpn6 = 0;
8927 185 tempitem.wpn7 = 0;
8928 185 tempitem.wpn8 = 0;
8929 185 tempitem.wpn9 = 0;
8930 185 tempitem.wpn10 = 0;
8931 185 break;
8932 }
8933 case itype_chargering:
8934 {
8935 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8936 184 tempitem.misc3 = 0;
8937 184 tempitem.misc4 = 0;
8938 184 tempitem.misc5 = 0;
8939 184 tempitem.misc6 = 0;
8940 184 tempitem.misc7 = 0;
8941 184 tempitem.misc8 = 0;
8942 184 tempitem.misc9 = 0;
8943 184 tempitem.misc10 = 0;
8944 184 tempitem.wpn = 0;
8945 184 tempitem.wpn2 = 0;
8946 184 tempitem.wpn3 = 0;
8947 184 tempitem.wpn4 = 0;
8948 184 tempitem.wpn5 = 0;
8949 184 tempitem.wpn6 = 0;
8950 184 tempitem.wpn7 = 0;
8951 184 tempitem.wpn8 = 0;
8952 184 tempitem.wpn9 = 0;
8953 184 tempitem.wpn10 = 0;
8954 184 break;
8955 }
8956 case itype_perilscroll:
8957 {
8958 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8959 92 tempitem.misc2 = 0;
8960 92 tempitem.misc3 = 0;
8961 92 tempitem.misc4 = 0;
8962 92 tempitem.misc5 = 0;
8963 92 tempitem.misc6 = 0;
8964 92 tempitem.misc7 = 0;
8965 92 tempitem.misc8 = 0;
8966 92 tempitem.misc9 = 0;
8967 92 tempitem.misc10 = 0;
8968 92 tempitem.wpn = 0;
8969 92 tempitem.wpn2 = 0;
8970 92 tempitem.wpn3 = 0;
8971 92 tempitem.wpn4 = 0;
8972 92 tempitem.wpn5 = 0;
8973 92 tempitem.wpn6 = 0;
8974 92 tempitem.wpn7 = 0;
8975 92 tempitem.wpn8 = 0;
8976 92 tempitem.wpn9 = 0;
8977 92 tempitem.wpn10 = 0;
8978 92 break;
8979 }
8980 case itype_wealthmedal:
8981 {
8982 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8983 277 tempitem.misc2 = 0;
8984 277 tempitem.misc3 = 0;
8985 277 tempitem.misc4 = 0;
8986 277 tempitem.misc5 = 0;
8987 277 tempitem.misc6 = 0;
8988 277 tempitem.misc7 = 0;
8989 277 tempitem.misc8 = 0;
8990 277 tempitem.misc9 = 0;
8991 277 tempitem.misc10 = 0;
8992 277 tempitem.wpn = 0;
8993 277 tempitem.wpn2 = 0;
8994 277 tempitem.wpn3 = 0;
8995 277 tempitem.wpn4 = 0;
8996 277 tempitem.wpn5 = 0;
8997 277 tempitem.wpn6 = 0;
8998 277 tempitem.wpn7 = 0;
8999 277 tempitem.wpn8 = 0;
9000 277 tempitem.wpn9 = 0;
9001 277 tempitem.wpn10 = 0;
9002 277 break;
9003 }
9004 case itype_heartring:
9005 {
9006 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9007 278 tempitem.misc3 = 0;
9008 278 tempitem.misc4 = 0;
9009 278 tempitem.misc5 = 0;
9010 278 tempitem.misc6 = 0;
9011 278 tempitem.misc7 = 0;
9012 278 tempitem.misc8 = 0;
9013 278 tempitem.misc9 = 0;
9014 278 tempitem.misc10 = 0;
9015 278 tempitem.wpn = 0;
9016 278 tempitem.wpn2 = 0;
9017 278 tempitem.wpn3 = 0;
9018 278 tempitem.wpn4 = 0;
9019 278 tempitem.wpn5 = 0;
9020 278 tempitem.wpn6 = 0;
9021 278 tempitem.wpn7 = 0;
9022 278 tempitem.wpn8 = 0;
9023 278 tempitem.wpn9 = 0;
9024 278 tempitem.wpn10 = 0;
9025 278 break;
9026 }
9027 case itype_magicring:
9028 {
9029 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9030 372 tempitem.misc3 = 0;
9031 372 tempitem.misc4 = 0;
9032 372 tempitem.misc5 = 0;
9033 372 tempitem.misc6 = 0;
9034 372 tempitem.misc7 = 0;
9035 372 tempitem.misc8 = 0;
9036 372 tempitem.misc9 = 0;
9037 372 tempitem.misc10 = 0;
9038 372 tempitem.wpn = 0;
9039 372 tempitem.wpn2 = 0;
9040 372 tempitem.wpn3 = 0;
9041 372 tempitem.wpn4 = 0;
9042 372 tempitem.wpn5 = 0;
9043 372 tempitem.wpn6 = 0;
9044 372 tempitem.wpn7 = 0;
9045 372 tempitem.wpn8 = 0;
9046 372 tempitem.wpn9 = 0;
9047 372 tempitem.wpn10 = 0;
9048 372 break;
9049 }
9050 case itype_spinscroll2:
9051 {
9052 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9053 92 tempitem.misc2 = 0;
9054 92 tempitem.misc3 = 0;
9055 92 tempitem.misc4 = 0;
9056 92 tempitem.misc5 = 0;
9057 92 tempitem.misc6 = 0;
9058 92 tempitem.misc7 = 0;
9059 92 tempitem.misc8 = 0;
9060 92 tempitem.misc9 = 0;
9061 92 tempitem.misc10 = 0;
9062 92 tempitem.wpn = 0;
9063 92 tempitem.wpn2 = 0;
9064 92 tempitem.wpn3 = 0;
9065 92 tempitem.wpn4 = 0;
9066 92 tempitem.wpn5 = 0;
9067 92 tempitem.wpn6 = 0;
9068 92 tempitem.wpn7 = 0;
9069 92 tempitem.wpn8 = 0;
9070 92 tempitem.wpn9 = 0;
9071 92 tempitem.wpn10 = 0;
9072 92 break;
9073 }
9074 case itype_quakescroll2:
9075 {
9076 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9077 92 tempitem.misc3 = 0;
9078 92 tempitem.misc4 = 0;
9079 92 tempitem.misc5 = 0;
9080 92 tempitem.misc6 = 0;
9081 92 tempitem.misc7 = 0;
9082 92 tempitem.misc8 = 0;
9083 92 tempitem.misc9 = 0;
9084 92 tempitem.misc10 = 0;
9085 92 tempitem.wpn = 0;
9086 92 tempitem.wpn2 = 0;
9087 92 tempitem.wpn3 = 0;
9088 92 tempitem.wpn4 = 0;
9089 92 tempitem.wpn5 = 0;
9090 92 tempitem.wpn6 = 0;
9091 92 tempitem.wpn7 = 0;
9092 92 tempitem.wpn8 = 0;
9093 92 tempitem.wpn9 = 0;
9094 92 tempitem.wpn10 = 0;
9095 92 break;
9096 }
9097 case itype_agony:
9098 {
9099 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9100 92 tempitem.misc2 = 0;
9101 92 tempitem.misc3 = 0;
9102 92 tempitem.misc4 = 0;
9103 92 tempitem.misc5 = 0;
9104 92 tempitem.misc6 = 0;
9105 92 tempitem.misc7 = 0;
9106 92 tempitem.misc8 = 0;
9107 92 tempitem.misc9 = 0;
9108 92 tempitem.misc10 = 0;
9109 92 tempitem.wpn = 0;
9110 92 tempitem.wpn2 = 0;
9111 92 tempitem.wpn3 = 0;
9112 92 tempitem.wpn4 = 0;
9113 92 tempitem.wpn5 = 0;
9114 92 tempitem.wpn6 = 0;
9115 92 tempitem.wpn7 = 0;
9116 92 tempitem.wpn8 = 0;
9117 92 tempitem.wpn9 = 0;
9118 92 tempitem.wpn10 = 0;
9119 92 break;
9120 }
9121 case itype_stompboots:
9122 {
9123 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9124 92 tempitem.misc1 = 0;
9125 92 tempitem.misc2 = 0;
9126 92 tempitem.misc3 = 0;
9127 92 tempitem.misc4 = 0;
9128 92 tempitem.misc5 = 0;
9129 92 tempitem.misc6 = 0;
9130 92 tempitem.misc7 = 0;
9131 92 tempitem.misc8 = 0;
9132 92 tempitem.misc9 = 0;
9133 92 tempitem.misc10 = 0;
9134 92 tempitem.wpn = 0;
9135 92 tempitem.wpn2 = 0;
9136 92 tempitem.wpn3 = 0;
9137 92 tempitem.wpn4 = 0;
9138 92 tempitem.wpn5 = 0;
9139 92 tempitem.wpn6 = 0;
9140 92 tempitem.wpn7 = 0;
9141 92 tempitem.wpn8 = 0;
9142 92 tempitem.wpn9 = 0;
9143 92 tempitem.wpn10 = 0;
9144 92 break;
9145 }
9146 case itype_whimsicalring:
9147 {
9148 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9149 92 tempitem.misc2 = 0;
9150 92 tempitem.misc3 = 0;
9151 92 tempitem.misc4 = 0;
9152 92 tempitem.misc5 = 0;
9153 92 tempitem.misc6 = 0;
9154 92 tempitem.misc7 = 0;
9155 92 tempitem.misc8 = 0;
9156 92 tempitem.misc9 = 0;
9157 92 tempitem.misc10 = 0;
9158 92 tempitem.wpn = 0;
9159 92 tempitem.wpn2 = 0;
9160 92 tempitem.wpn3 = 0;
9161 92 tempitem.wpn4 = 0;
9162 92 tempitem.wpn5 = 0;
9163 92 tempitem.wpn6 = 0;
9164 92 tempitem.wpn7 = 0;
9165 92 tempitem.wpn8 = 0;
9166 92 tempitem.wpn9 = 0;
9167 92 tempitem.wpn10 = 0;
9168 92 break;
9169 }
9170 case itype_perilring:
9171 {
9172 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9173 93 tempitem.misc2 = 0;
9174 93 tempitem.misc3 = 0;
9175 93 tempitem.misc4 = 0;
9176 93 tempitem.misc5 = 0;
9177 93 tempitem.misc6 = 0;
9178 93 tempitem.misc7 = 0;
9179 93 tempitem.misc8 = 0;
9180 93 tempitem.misc9 = 0;
9181 93 tempitem.misc10 = 0;
9182 93 tempitem.wpn = 0;
9183 93 tempitem.wpn2 = 0;
9184 93 tempitem.wpn3 = 0;
9185 93 tempitem.wpn4 = 0;
9186 93 tempitem.wpn5 = 0;
9187 93 tempitem.wpn6 = 0;
9188 93 tempitem.wpn7 = 0;
9189 93 tempitem.wpn8 = 0;
9190 93 tempitem.wpn9 = 0;
9191 93 tempitem.wpn10 = 0;
9192 93 break;
9193 }
9194 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9195 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9196 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9197 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9198 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9199 {
9200 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9201 2541 tempitem.misc1 = 0;
9202 2541 tempitem.misc2 = 0;
9203 2541 tempitem.misc3 = 0;
9204 2541 tempitem.misc4 = 0;
9205 2541 tempitem.misc5 = 0;
9206 2541 tempitem.misc6 = 0;
9207 2541 tempitem.misc7 = 0;
9208 2541 tempitem.misc8 = 0;
9209 2541 tempitem.misc9 = 0;
9210 2541 tempitem.misc10 = 0;
9211 2541 tempitem.wpn = 0;
9212 2541 tempitem.wpn2 = 0;
9213 2541 tempitem.wpn3 = 0;
9214 2541 tempitem.wpn4 = 0;
9215 2541 tempitem.wpn5 = 0;
9216 2541 tempitem.wpn6 = 0;
9217 2541 tempitem.wpn7 = 0;
9218 2541 tempitem.wpn8 = 0;
9219 2541 tempitem.wpn9 = 0;
9220 2541 tempitem.wpn10 = 0;
9221 2541 break;
9222 }
9223 }
9224 23808 }
9225 //Port quest rules to items
9226
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 31)
9227 {
9228
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9229 {
9230
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9231 90 else tempitem.flags &= ~ ITEM_FLAG2;
9232 107 }
9233
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9234 {
9235
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9236 75 else tempitem.flags &= ~ ITEM_FLAG2;
9237 92 }
9238
9239
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9240 {
9241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9242 277 else tempitem.flags &= ~ ITEM_FLAG4;
9243 277 }
9244
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9245 {
9246
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9247 105 else tempitem.flags &= ~ ITEM_FLAG3;
9248 107 }
9249 23808 }
9250
9251 //Port quest rules to items
9252
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 37)
9253 {
9254
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9255 {
9256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9257 93 else tempitem.flags &= ~ ITEM_FLAG1;
9258 93 }
9259
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9260 {
9261
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9262 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9263 7811 }
9264
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9265 {
9266
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9267 104 else tempitem.flags &= ~ ITEM_FLAG5;
9268 107 }
9269
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9270 {
9271 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9272
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9273 257 else tempitem.flags &= ~ ITEM_FLAG3;
9274 329 }
9275 23808 }
9276
9277
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 38)
9278 {
9279
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9280 {
9281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9282 461 else tempitem.flags &= ~ITEM_FLAG4;
9283
9284
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9285 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9286 461 }
9287
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9288 {
9289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9290 274 else tempitem.flags &= ~ITEM_FLAG4;
9291
9292
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9293 270 else tempitem.flags |= ITEM_FLAG2;
9294 274 }
9295 23808 }
9296
9297
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 39)
9298 {
9299
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9300 {
9301
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9302 409 else tempitem.flags &= ~ITEM_FLAG5;
9303 421 }
9304
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9305 {
9306
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9307 {
9308 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9309 24 }
9310 else
9311 {
9312 159 tempitem.flags |= ITEM_FLAG3;
9313
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9314 74 else tempitem.flags &= ~ITEM_FLAG4;
9315 }
9316 183 }
9317
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9318 {
9319
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9320 {
9321 30 tempitem.flags |= ITEM_FLAG3;
9322
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9323 24 else tempitem.flags &= ~ITEM_FLAG4;
9324 30 }
9325 else
9326 {
9327 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9328 }
9329 184 }
9330 23808 }
9331
9332
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 40)
9333 {
9334
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9335 {
9336
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9337 348 else tempitem.flags &= ~ITEM_FLAG1;
9338 395 }
9339
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9340 {
9341
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9342 8151 else tempitem.flags &= ~ITEM_FLAG8;
9343 8232 }
9344
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9345 {
9346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9347 8011 else tempitem.flags &= ~ITEM_FLAG7;
9348 8011 }
9349
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9350 {
9351 92 tempitem.flags |= ITEM_FLAG7;
9352 92 }
9353 23808 }
9354
9355
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 41 )
9356 {
9357
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9358 {
9359
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9360 7742 else tempitem.flags &= ~ITEM_FLAG9;
9361
9362
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9363 7742 else tempitem.flags &= ~ITEM_FLAG10;
9364 7811 }
9365 23808 }
9366
9367
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 42 )
9368 {
9369
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9370 {
9371
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9372 105 else tempitem.flags &= ~ITEM_FLAG3;
9373
9374 107 tempitem.flags &= ~ITEM_FLAG6;
9375 107 }
9376
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9377 {
9378 93 tempitem.flags &= ~ITEM_FLAG3;
9379 93 }
9380
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9381 {
9382 92 tempitem.flags |= ITEM_FLAG3;
9383
9384 92 tempitem.flags &= ~ITEM_FLAG6;
9385 92 }
9386
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9387 {
9388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9389 7811 else tempitem.flags &= ~ITEM_FLAG6;
9390 7811 }
9391 23808 }
9392
9393
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 43 )
9394 {
9395
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9396 {
9397
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9398 135 else tempitem.flags &= ~ITEM_FLAG3;
9399 138 }
9400 23808 }
9401
9402
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 45 )
9403 {
9404
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9405 {
9406 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9407 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9408 93 }
9409 23808 }
9410
9411
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 46 )
9412 {
9413
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9414 {
9415 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9416 92 }
9417 23808 }
9418
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 34 ) //! set the default counter for older quests.
9419 {
9420
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9421 {
9422 75 tempitem.cost_counter[0] = 1;
9423 75 }
9424 else
9425 {
9426
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9427 4608 tempitem.cost_counter[0] = 4;
9428 else
9429 {
9430 19125 tempitem.cost_amount[0] = 0;
9431 19125 tempitem.cost_counter[0] = -1;
9432 }
9433 }
9434 23808 }
9435
9436
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 35 ) //new Lens of Truth flags
9437 {
9438
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9439 {
9440
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9441 {
9442 3 tempitem.flags |= ITEM_FLAG4;
9443 3 }
9444
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9445 {
9446 52 tempitem.flags |= ITEM_FLAG1;
9447 52 }
9448
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9449 {
9450 4 tempitem.flags |= ITEM_FLAG5;
9451 4 }
9452 92 }
9453 23808 }
9454
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9455 {
9456
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9457 {
9458 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9459 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9460 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9461 190464 tempitem.sprite_initiald[q] = 0;
9462 190464 }
9463
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9464 23808 tempitem.sprite_script = 0;
9465 23808 }
9466
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9467 {
9468 23808 tempitem.pickupflag = 0;
9469 23808 }
9470
9471
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 51 )
9472 {
9473
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9474 {
9475 222 tempitem.misc4 = 50; //Step speed
9476 222 }
9477 23808 }
9478
9479
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 52 )
9480 {
9481
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9482 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9483 23808 }
9484
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if(s_version < 53)
9485 {
9486
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23335 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9487 {
9488 case itype_arrow:
9489 274 tempitem.cost_counter[1] = crARROWS;
9490 274 tempitem.cost_amount[1] = 1;
9491 274 break;
9492 case itype_bomb:
9493 107 tempitem.cost_counter[1] = crBOMBS;
9494 107 tempitem.cost_amount[1] = 1;
9495 107 break;
9496 case itype_sbomb:
9497 92 tempitem.cost_counter[1] = crSBOMBS;
9498 92 tempitem.cost_amount[1] = 1;
9499 92 break;
9500 default:
9501 23335 tempitem.cost_counter[1] = crNONE;
9502 23335 tempitem.cost_amount[1] = 0;
9503 23335 }
9504 23808 tempitem.magiccosttimer[1] = 0;
9505 23808 }
9506
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if( s_version < 54 )
9507 {
9508
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9509 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9510 25088 }
9511
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if(s_version < 55)
9512 {
9513
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9514 {
9515 case itype_spinscroll:
9516 case itype_quakescroll:
9517 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9518 194 break;
9519 case itype_spinscroll2:
9520 case itype_quakescroll2:
9521 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9522 194 break;
9523 }
9524 25088 }
9525
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if(s_version < 56)
9526 {
9527
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9528 {
9529 case itype_divinefire:
9530
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9531
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9532 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9533 97 break;
9534 case itype_candle:
9535
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9536 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9537 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9538 234 break;
9539 case itype_book:
9540 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9541 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9542 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9543 112 break;
9544 }
9545 25088 }
9546
9547
2/2
✓ Branch 0 taken 30880 times.
✓ Branch 1 taken 2144 times.
33024 if(tempitem.fam_type==0) // Always do this
9548 2144 tempitem.fam_type=1;
9549
9550 33024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9551 33024 }
9552
9553 129 return 0;
9554 129 }
9555
9556 static bool did_init_def_items = false;
9557 66240 void init_def_items()
9558 {
9559
2/2
✓ Branch 0 taken 66124 times.
✓ Branch 1 taken 116 times.
66240 if(did_init_def_items) return;
9560 116 did_init_def_items = true;
9561 116 default_items[3].cost_counter[1] = crBOMBS;
9562 116 default_items[13].cost_counter[1] = crARROWS;
9563 116 default_items[14].cost_counter[1] = crARROWS;
9564 116 default_items[48].cost_counter[1] = crSBOMBS;
9565 116 default_items[57].cost_counter[1] = crARROWS;
9566 66240 }
9567 66240 void reset_itembuf(itemdata *item, int32_t id)
9568 {
9569 66240 init_def_items();
9570
2/2
✓ Branch 0 taken 28250 times.
✓ Branch 1 taken 37990 times.
66240 if(id<iLast)
9571 {
9572 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9573 37990 word tile = item->tile;
9574 37990 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9575 37990 int32_t ltm = item->ltm;
9576
9577 37990 memcpy(item,&default_items[id],sizeof(itemdata));
9578 37990 item->tile = tile;
9579 37990 item->misc_flags = miscs;
9580 37990 item->csets = cset;
9581 37990 item->frames = frames;
9582 37990 item->speed = speed;
9583 37990 item->delay = delay;
9584 37990 item->ltm = ltm;
9585 37990 }
9586 66240 }
9587
9588 33792 void reset_itemname(int32_t id)
9589 {
9590 33792 sprintf(item_string[id],"zz%03d",id);
9591
9592
2/2
✓ Branch 0 taken 14916 times.
✓ Branch 1 taken 18876 times.
33792 if(id < iLast)
9593 18876 strcpy(item_string[id],old_item_string[id]);
9594 33792 }
9595
9596 129 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9597 {
9598 129 word weapons_to_read=MAXWPNS;
9599 int32_t dummy;
9600 byte padding;
9601 wpndata tempweapon;
9602 129 word s_version=0, s_cversion=0;
9603
9604
9605
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x186)
9606 {
9607 weapons_to_read=64;
9608 }
9609
9610
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x185)
9611 {
9612 weapons_to_read=32;
9613 }
9614
9615
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
9616 {
9617 125 weapons_to_read=0;
9618
9619 //section version info
9620
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
9621 {
9622 return qe_invalid;
9623 }
9624
9625 125 FFCore.quest_format[vWeaponSprites] = s_version;
9626
9627 //al_trace("Weapons version %d\n", s_version);
9628
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
9629 {
9630 return qe_invalid;
9631 }
9632
9633 //section size
9634
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
9635 {
9636 return qe_invalid;
9637 }
9638
9639 //finally... section data
9640
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&weapons_to_read,f))
9641 {
9642 return qe_invalid;
9643 }
9644
9645
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9646 {
9647 return qe_invalid;
9648 }
9649 125 }
9650
9651
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>2)
9652 {
9653
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<weapons_to_read; i++)
9654 {
9655 char tempname[64];
9656
9657
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
9658 {
9659 return qe_invalid;
9660 }
9661
9662 28928 weapon_string[i][0] = '\0';
9663 28928 strncat(weapon_string[i], tempname, 64 - 1);
9664 28928 }
9665
9666
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<4)
9667 {
9668 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9669 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9670 }
9671
9672
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<5)
9673 {
9674 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9675 }
9676
9677 /*
9678 if (s_version<6)
9679 {
9680 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9681 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9682 }
9683 */
9684 113 }
9685 else
9686 {
9687
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9688 4096 reset_weaponname(i);
9689 }
9690
9691
2/2
✓ Branch 0 taken 30768 times.
✓ Branch 1 taken 129 times.
30897 for(int32_t i=0; i<weapons_to_read; i++)
9692 {
9693 30768 word oldtile = 0;
9694
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 22064 times.
30768 if (s_version < 8)
9695 {
9696
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9697 return qe_invalid;
9698 22064 }
9699
9700
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.misc,f))
9701 {
9702 return qe_invalid;
9703 }
9704
9705
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.csets,f))
9706 {
9707 return qe_invalid;
9708 }
9709
9710
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.frames,f))
9711 {
9712 return qe_invalid;
9713 }
9714
9715
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.speed,f))
9716 {
9717 return qe_invalid;
9718 }
9719
9720
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.type,f))
9721 {
9722 return qe_invalid;
9723 }
9724
9725
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9216 times.
30768 if ( s_version >= 7 )
9726 {
9727
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempweapon.script,f))
9728 {
9729 return qe_invalid;
9730 }
9731
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempweapon.tile,f))
9732 {
9733 return qe_invalid;
9734 }
9735 9216 }
9736
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21552 times.
30768 if ( s_version < 7 )
9737 {
9738 21552 tempweapon.tile = oldtile;
9739 21552 }
9740
9741
2/2
✓ Branch 0 taken 29744 times.
✓ Branch 1 taken 1024 times.
30768 if(Header->zelda_version < 0x193)
9742 {
9743
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9744 {
9745 return qe_invalid;
9746 }
9747 1024 }
9748
9749
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 1840 times.
30768 if(s_version < 6)
9750 {
9751
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9752 {
9753 4 tempweapon.misc |= WF_BEHIND;
9754 4 }
9755 else
9756 1836 tempweapon.misc &= ~WF_BEHIND;
9757 1840 }
9758
9759 30768 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9760 30768 }
9761
9762
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<2)
9763 {
9764 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9765 16 }
9766
9767
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
9768 {
9769 16 wpnsbuf[iwQuarterHearts].tile=1;
9770 16 wpnsbuf[iwQuarterHearts].csets=1;
9771 16 }
9772
9773
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x176)
9774 {
9775 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9776 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9777 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9778 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9779 }
9780
9781
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
9782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9783 {
9784 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9785 4 }
9786
9787
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if((Header->zelda_version < 0x210))
9788 {
9789 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9790 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9791 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9792 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9793 4 }
9794
9795 129 return 0;
9796 129 }
9797
9798 129 void init_guys(int32_t guyversion)
9799 {
9800
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<MAXGUYS; i++)
9801 {
9802 66048 guysbuf[i] = default_guys[0];
9803 66048 }
9804
9805
2/2
✓ Branch 0 taken 22833 times.
✓ Branch 1 taken 129 times.
22962 for(int32_t i=0; i<OLDMAXGUYS; i++)
9806 {
9807 22833 guysbuf[i] = default_guys[i];
9808
2/2
✓ Branch 0 taken 22575 times.
✓ Branch 1 taken 258 times.
22833 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9809 22833 guysbuf[i].spr_death = iwDeath;
9810 22833 guysbuf[i].spr_spawn = iwSpawn;
9811 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9812
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20001 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
22833 if(guyversion<=3 && i==ePATRABS)
9813 {
9814 16 guysbuf[i].bosspal=spDIG;
9815 16 guysbuf[i].cset=14;
9816 16 guysbuf[i].misc9=14;
9817 16 }
9818
9819
2/2
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 2832 times.
22833 if(guyversion<=3)
9820 {
9821 // Rope/Ghini Flash rules
9822
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9823 {
9824
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9825 {
9826 12 guysbuf[i].flags2 &= ~guy_flashing;
9827 12 }
9828 2124 }
9829
9830
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9831 {
9832
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9833 {
9834 18 guysbuf[i].flags2 &= ~guy_flashing;
9835 18 }
9836 531 }
9837
9838
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9839 {
9840
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9841 {
9842 3 guysbuf[i].flags2 |= guy_blinking;
9843 3 }
9844
9845
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9846 {
9847 guysbuf[i].flags2 |= guy_transparent;
9848 }
9849 16 }
9850 2832 }
9851
9852 // Darknut fix
9853
10/10
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22575 times.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 22446 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 22317 times.
✓ Branch 7 taken 129 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 22188 times.
22833 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9854 {
9855
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 210 times.
645 if(get_qr(qr_NEWENEMYTILES))
9856 {
9857 435 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9858 435 guysbuf[i].s_width=guysbuf[i].e_width;
9859 435 guysbuf[i].s_height=guysbuf[i].e_height;
9860 435 }
9861 210 else guysbuf[i].s_tile=860;
9862
9863
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 80 times.
645 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9864 {
9865 80 guysbuf[i].flags |= guy_bkshield;
9866 80 }
9867 645 }
9868
9869
4/4
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22825 times.
✓ Branch 3 taken 8 times.
22833 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9870 {
9871 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9872 8 }
9873 22833 }
9874 129 }
9875
9876 4096 void reset_weaponname(int32_t i)
9877 {
9878
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9879 {
9880 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9881 1408 }
9882 else
9883 2688 sprintf(weapon_string[i],"zz%03d",i);
9884 4096 }
9885
9886 129 void init_item_drop_sets()
9887 {
9888
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9889 {
9890 // item_drop_sets[i] = default_item_drop_sets[0];
9891 33024 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9892 33024 }
9893
9894
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 129 times.
1806 for(int32_t i=0; i<isMAX; i++)
9895 {
9896 1677 item_drop_sets[i] = default_item_drop_sets[i];
9897
9898 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9899
2/2
✓ Branch 0 taken 16770 times.
✓ Branch 1 taken 1677 times.
18447 for(int32_t j=0; j<10; ++j)
9900 {
9901 16770 int32_t it = item_drop_sets[i].item[j];
9902
9903
3/4
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 4994 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 756 times.
16770 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9904
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 11020 times.
11776 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9905 {
9906 756 item_drop_sets[i].chance[j+1]=0;
9907 756 }
9908
3/4
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 15498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
16014 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9909 {
9910 item_drop_sets[i].chance[j+1]=0;
9911 }
9912
9913 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9914
2/2
✓ Branch 0 taken 16762 times.
✓ Branch 1 taken 8 times.
16770 if(itemsbuf[it].family == itype_misc)
9915 {
9916 // If a non-gameplay item was selected, then item drop was aborted.
9917 // Reflect this by increasing the 'Nothing' chance accordingly.
9918 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9919 8 item_drop_sets[i].chance[j+1]=0;
9920 8 }
9921 16770 }
9922 1677 }
9923 129 }
9924
9925 125 void init_favorites()
9926 {
9927
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9928 {
9929 37500 favorite_combos[i]=-1;
9930 37500 }
9931
9932
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9933 {
9934 37500 favorite_comboaliases[i]=-1;
9935 37500 }
9936 125 }
9937
9938 const char *ctype_name[cMAX]=
9939 {
9940 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9941 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9942 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9943 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9944 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9945 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9946 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9947 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9948 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9949 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9950 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9951 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9952 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9953 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9954 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9955 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9956 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9957 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9958 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9959 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9960 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9961 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9962 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9963 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9964 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9965 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9966 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9967 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9968
9969 };
9970
9971 224 int32_t init_combo_classes()
9972 {
9973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
224 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9974
2/2
✓ Branch 0 taken 40544 times.
✓ Branch 1 taken 224 times.
40768 for(int32_t i=0; i<cMAX; i++)
9975 {
9976 40544 combo_class_buf[i] = default_combo_classes[i];
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40544 times.
40544 if ( char const* nm = zi->getComboTypeName(i) )
9978 {
9979 40544 size_t len = strlen(nm);
9980
2/2
✓ Branch 0 taken 2594816 times.
✓ Branch 1 taken 40544 times.
2635360 for ( size_t q = 0; q < 64; q++ )
9981 {
9982
2/2
✓ Branch 0 taken 599200 times.
✓ Branch 1 taken 1995616 times.
2594816 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9983 2594816 }
9984 40544 }
9985 40544 }
9986
9987 224 return 0;
9988 }
9989
9990 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9991 {
9992
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9993 //these are here to bypass compiler warnings about unused arguments
9994 97 cv_herosprites=cv_herosprites;
9995
9996 97 zinit.hero_swim_speed=67; //default
9997 97 setupherotiles(zinit.heroAnimationStyle);
9998 97 setupherodefenses();
9999 97 setupherooffsets();
10000
10001
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
10002 {
10003 word tile, tile2;
10004 byte flip, extend, dummy_byte;
10005
10006
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10007 {
10008
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10009 {
10010 return qe_invalid;
10011 }
10012
10013
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10019 {
10020 return qe_invalid;
10021 }
10022
10023 308 walkspr[i][spr_tile]=(int32_t)tile;
10024 308 walkspr[i][spr_flip]=(int32_t)flip;
10025 308 walkspr[i][spr_extend]=(int32_t)extend;
10026 308 }
10027
10028
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10029 {
10030
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10031 {
10032 return qe_invalid;
10033 }
10034
10035
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10041 {
10042 return qe_invalid;
10043 }
10044
10045 308 stabspr[i][spr_tile]=(int32_t)tile;
10046 308 stabspr[i][spr_flip]=(int32_t)flip;
10047 308 stabspr[i][spr_extend]=(int32_t)extend;
10048 308 }
10049
10050
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10051 {
10052
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10053 {
10054 return qe_invalid;
10055 }
10056
10057
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067 308 slashspr[i][spr_tile]=(int32_t)tile;
10068 308 slashspr[i][spr_flip]=(int32_t)flip;
10069 308 slashspr[i][spr_extend]=(int32_t)extend;
10070 308 }
10071
10072
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10073 {
10074
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10075 {
10076 return qe_invalid;
10077 }
10078
10079
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10080 {
10081 return qe_invalid;
10082 }
10083
10084
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10085 {
10086 return qe_invalid;
10087 }
10088
10089 308 floatspr[i][spr_tile]=(int32_t)tile;
10090 308 floatspr[i][spr_flip]=(int32_t)flip;
10091 308 floatspr[i][spr_extend]=(int32_t)extend;
10092 308 }
10093
10094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10095 {
10096
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10097 {
10098
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10099 {
10100 return qe_invalid;
10101 }
10102
10103
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10104 {
10105 return qe_invalid;
10106 }
10107
10108
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10109 {
10110 return qe_invalid;
10111 }
10112
10113 308 swimspr[i][spr_tile]=(int32_t)tile;
10114 308 swimspr[i][spr_flip]=(int32_t)flip;
10115 308 swimspr[i][spr_extend]=(int32_t)extend;
10116 308 }
10117 77 }
10118
10119
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10120 {
10121
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10122 {
10123 return qe_invalid;
10124 }
10125
10126
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10127 {
10128 return qe_invalid;
10129 }
10130
10131
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10132 {
10133 return qe_invalid;
10134 }
10135
10136 308 divespr[i][spr_tile]=(int32_t)tile;
10137 308 divespr[i][spr_flip]=(int32_t)flip;
10138 308 divespr[i][spr_extend]=(int32_t)extend;
10139 308 }
10140
10141
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10142 {
10143
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10144 {
10145 return qe_invalid;
10146 }
10147
10148
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10149 {
10150 return qe_invalid;
10151 }
10152
10153
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10154 {
10155 return qe_invalid;
10156 }
10157
10158 308 poundspr[i][spr_tile]=(int32_t)tile;
10159 308 poundspr[i][spr_flip]=(int32_t)flip;
10160 308 poundspr[i][spr_extend]=(int32_t)extend;
10161 308 }
10162
10163
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10164 {
10165 return qe_invalid;
10166 }
10167
10168 77 flip=0;
10169
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10171 {
10172
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10173 {
10174 return qe_invalid;
10175 }
10176 77 }
10177
10178
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10179 {
10180 return qe_invalid;
10181 }
10182
10183 77 castingspr[spr_tile]=(int32_t)tile;
10184 77 castingspr[spr_flip]=(int32_t)flip;
10185 77 castingspr[spr_extend]=(int32_t)extend;
10186
10187
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10188 {
10189 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10190
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10191 {
10192
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10193 {
10194
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10195 {
10196 return qe_invalid;
10197 }
10198
10199
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10210 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10211 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10212 308 }
10213 154 }
10214 77 }
10215 else
10216 {
10217 for(int32_t i=0; i<2; i++)
10218 {
10219 if(!p_igetw(&tile,f))
10220 {
10221 return qe_invalid;
10222 }
10223
10224 if(!p_igetw(&tile2,f))
10225 {
10226 return qe_invalid;
10227 }
10228
10229 if(!p_getc(&extend,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10235 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10236 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10237 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10238 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10239 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10240 }
10241 }
10242
10243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10244 {
10245
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10246 {
10247
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10248 {
10249 return qe_invalid;
10250 }
10251
10252
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10258 {
10259 return qe_invalid;
10260 }
10261
10262 308 jumpspr[i][spr_tile]=(int32_t)tile;
10263 308 jumpspr[i][spr_flip]=(int32_t)flip;
10264 308 jumpspr[i][spr_extend]=(int32_t)extend;
10265 308 }
10266 77 }
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10269 {
10270
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10271 {
10272
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10273 {
10274 return qe_invalid;
10275 }
10276
10277
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10283 {
10284 return qe_invalid;
10285 }
10286
10287 308 chargespr[i][spr_tile]=(int32_t)tile;
10288 308 chargespr[i][spr_flip]=(int32_t)flip;
10289 308 chargespr[i][spr_extend]=(int32_t)extend;
10290 308 }
10291 77 }
10292
10293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10294 {
10295
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10296 {
10297 return qe_invalid;
10298 }
10299
10300 77 zinit.hero_swim_speed=(byte)dummy_byte;
10301 77 }
10302
10303 77 memset(frozenspr, 0, sizeof(frozenspr));
10304 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10305 77 memset(onfirespr, 0, sizeof(onfirespr));
10306 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10307 77 memset(diggingspr, 0, sizeof(diggingspr));
10308 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10309 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10310 77 memset(pushingspr, 0, sizeof(pushingspr));
10311 77 memset(liftingspr, 0, sizeof(liftingspr));
10312 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10313 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10314 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10315 77 memset(fallingspr, 0, sizeof(fallingspr));
10316 77 memset(shockedspr, 0, sizeof(shockedspr));
10317 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10318 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10319 77 memset(readingspr, 0, sizeof(readingspr));
10320 77 memset(slash180spr, 0, sizeof(slash180spr));
10321 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10322 77 memset(dashspr, 0, sizeof(dashspr));
10323 77 memset(bonkspr, 0, sizeof(bonkspr));
10324 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10325 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10326 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10327
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10328 {
10329
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10330 {
10331 924 drowningspr[q][p] = divespr[q][p];
10332 924 drowning_lavaspr[q][p] = divespr[q][p];
10333 924 }
10334 308 }
10335 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10336 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10337 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10338 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10339 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10340 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10341 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10342 77 }
10343
10344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10345 {
10346 97 bool fastswim = zinit.hero_swim_speed > 60;
10347 // '2/3' or '1/2'
10348 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10349 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10350 97 }
10351 97 return 0;
10352 97 }
10353
10354 6120 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10355 {
10356 6120 arr[spr_tile] = tile;
10357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_flip] = (flip > 3 ? 0 : flip);
10358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_extend] = (ext > 2 ? 0 : ext);
10359 6120 }
10360 //Used to read the player sprites as int32_t, not word.
10361 36 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10362 {
10363 //these are here to bypass compiler warnings about unused arguments
10364 36 cv_herosprites=cv_herosprites;
10365
10366 36 zinit.hero_swim_speed=67; //default
10367 36 setupherotiles(zinit.heroAnimationStyle);
10368 36 setupherodefenses();
10369 36 setupherooffsets();
10370
10371 int32_t tile, tile2;
10372 byte flip, extend, dummy_byte;
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>=0)
10375 {
10376
10377
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10378 {
10379
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10380 {
10381 return qe_invalid;
10382 }
10383
10384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10385 {
10386 return qe_invalid;
10387 }
10388
10389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10390 {
10391 return qe_invalid;
10392 }
10393
10394 144 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10395 144 }
10396
10397
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10398 {
10399
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10400 {
10401 return qe_invalid;
10402 }
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10405 {
10406 return qe_invalid;
10407 }
10408
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10410 {
10411 return qe_invalid;
10412 }
10413
10414 144 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10415 144 }
10416
10417
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10418 {
10419
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10420 {
10421 return qe_invalid;
10422 }
10423
10424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10425 {
10426 return qe_invalid;
10427 }
10428
10429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10430 {
10431 return qe_invalid;
10432 }
10433
10434 144 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10435 144 }
10436
10437
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10438 {
10439
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10440 {
10441 return qe_invalid;
10442 }
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10445 {
10446 return qe_invalid;
10447 }
10448
10449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10450 {
10451 return qe_invalid;
10452 }
10453
10454 144 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10455 144 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>1)
10458 {
10459
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10460 {
10461
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10462 {
10463 return qe_invalid;
10464 }
10465
10466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10467 {
10468 return qe_invalid;
10469 }
10470
10471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10472 {
10473 return qe_invalid;
10474 }
10475
10476 144 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10477 144 }
10478 36 }
10479
10480
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10481 {
10482
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10483 {
10484 return qe_invalid;
10485 }
10486
10487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10488 {
10489 return qe_invalid;
10490 }
10491
10492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10493 {
10494 return qe_invalid;
10495 }
10496
10497 144 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10498 144 }
10499
10500
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10501 {
10502
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10503 {
10504 return qe_invalid;
10505 }
10506
10507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10508 {
10509 return qe_invalid;
10510 }
10511
10512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10513 {
10514 return qe_invalid;
10515 }
10516
10517 144 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10518 144 }
10519
10520
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
10521 {
10522 return qe_invalid;
10523 }
10524
10525 36 flip=0;
10526
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>0)
10528 {
10529
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
10530 {
10531 return qe_invalid;
10532 }
10533 36 }
10534
10535
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
10536 {
10537 return qe_invalid;
10538 }
10539
10540 36 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10541
10542
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>0)
10543 {
10544 36 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10545
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 36 times.
108 for(int32_t i=0; i<2; i++)
10546 {
10547
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 72 times.
288 for(int32_t j=0; j<num_holdsprs; j++)
10548 {
10549
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_igetl(&tile,f))
10550 {
10551 return qe_invalid;
10552 }
10553
10554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&flip,f))
10555 {
10556 return qe_invalid;
10557 }
10558
10559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&extend,f))
10560 {
10561 return qe_invalid;
10562 }
10563
10564 216 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10565 216 }
10566 72 }
10567 36 }
10568 else
10569 {
10570 for(int32_t i=0; i<2; i++)
10571 {
10572 if(!p_igetl(&tile,f))
10573 {
10574 return qe_invalid;
10575 }
10576
10577 if(!p_igetl(&tile2,f))
10578 {
10579 return qe_invalid;
10580 }
10581
10582 if(!p_getc(&extend,f))
10583 {
10584 return qe_invalid;
10585 }
10586
10587 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10588 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10589 }
10590 }
10591
10592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>2)
10593 {
10594
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10595 {
10596
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10597 {
10598 return qe_invalid;
10599 }
10600
10601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10602 {
10603 return qe_invalid;
10604 }
10605
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10607 {
10608 return qe_invalid;
10609 }
10610
10611 144 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10612 144 }
10613 36 }
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>3)
10616 {
10617
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10618 {
10619
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10620 {
10621 return qe_invalid;
10622 }
10623
10624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10625 {
10626 return qe_invalid;
10627 }
10628
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10630 {
10631 return qe_invalid;
10632 }
10633
10634 144 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10635 144 }
10636 36 }
10637
10638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>4)
10639 {
10640
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&dummy_byte,f))
10641 {
10642 return qe_invalid;
10643 }
10644
10645 36 zinit.hero_swim_speed=(byte)dummy_byte;
10646 36 }
10647
10648
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>6)
10649 {
10650
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10651 {
10652
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10653 return qe_invalid;
10654
10655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10656 return qe_invalid;
10657
10658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10659 return qe_invalid;
10660
10661 144 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10662 144 }
10663
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10664 {
10665
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10672 return qe_invalid;
10673
10674 144 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10675 144 }
10676
10677
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10678 {
10679
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10680 return qe_invalid;
10681
10682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10683 return qe_invalid;
10684
10685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10686 return qe_invalid;
10687
10688 144 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10689 144 }
10690
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10691 {
10692
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10693 return qe_invalid;
10694
10695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10696 return qe_invalid;
10697
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10699 return qe_invalid;
10700
10701 144 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10702 144 }
10703
10704
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10705 {
10706
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10707 return qe_invalid;
10708
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10710 return qe_invalid;
10711
10712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10713 return qe_invalid;
10714
10715 144 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10716 144 }
10717
10718
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10719 {
10720
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10721 return qe_invalid;
10722
10723
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10724 return qe_invalid;
10725
10726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10727 return qe_invalid;
10728
10729 144 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10730 144 }
10731
10732
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10733 {
10734
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10735 return qe_invalid;
10736
10737
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10738 return qe_invalid;
10739
10740
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10741 return qe_invalid;
10742
10743 144 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10744 144 }
10745
10746
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10747 {
10748
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10749 return qe_invalid;
10750
10751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10752 return qe_invalid;
10753
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10755 return qe_invalid;
10756
10757 144 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10758 144 }
10759
10760
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10761 {
10762
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10763 return qe_invalid;
10764
10765
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10766 return qe_invalid;
10767
10768
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10769 return qe_invalid;
10770
10771 144 byte frames = 0;
10772
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 136 times.
144 if(v_herosprites > 15)
10773 {
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(!p_getc(&frames,f))
10775 return qe_invalid;
10776 136 }
10777
10778 144 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10779 144 liftingspr[q][spr_frames] = frames;
10780 144 }
10781
10782
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10783 {
10784
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10785 return qe_invalid;
10786
10787
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10788 return qe_invalid;
10789
10790
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10791 return qe_invalid;
10792
10793 144 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10794 144 }
10795
10796
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10797 {
10798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10799 return qe_invalid;
10800
10801
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10802 return qe_invalid;
10803
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10805 return qe_invalid;
10806
10807 144 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10808 144 }
10809
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10810 {
10811
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10812 return qe_invalid;
10813
10814
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10815 return qe_invalid;
10816
10817
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10818 return qe_invalid;
10819
10820 144 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10821 144 }
10822
10823
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10824 {
10825
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10826 return qe_invalid;
10827
10828
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10829 return qe_invalid;
10830
10831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10832 return qe_invalid;
10833
10834 144 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10835 144 }
10836
10837
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10838 {
10839
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10840 return qe_invalid;
10841
10842
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10843 return qe_invalid;
10844
10845
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10846 return qe_invalid;
10847
10848 144 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10849 144 }
10850
10851
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10852 {
10853
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10854 return qe_invalid;
10855
10856
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10857 return qe_invalid;
10858
10859
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10860 return qe_invalid;
10861
10862 144 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10863 144 }
10864
10865
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10866 {
10867
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10868 return qe_invalid;
10869
10870
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10871 return qe_invalid;
10872
10873
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10874 return qe_invalid;
10875
10876 144 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10877 144 }
10878
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10879 {
10880
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10881 return qe_invalid;
10882
10883
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10884 return qe_invalid;
10885
10886
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10887 return qe_invalid;
10888
10889 144 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10890 144 }
10891
10892
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10893 {
10894
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10895 return qe_invalid;
10896
10897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10898 return qe_invalid;
10899
10900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10901 return qe_invalid;
10902
10903 144 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10904 144 }
10905
10906
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10907 {
10908
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10915 return qe_invalid;
10916
10917 144 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10918 144 }
10919
10920
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10921 {
10922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10923 return qe_invalid;
10924
10925
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10926 return qe_invalid;
10927
10928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10929 return qe_invalid;
10930
10931 144 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10932 144 }
10933
10934
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10935 {
10936
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10937 return qe_invalid;
10938
10939
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10940 return qe_invalid;
10941
10942
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10943 return qe_invalid;
10944
10945 144 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10946 144 }
10947
10948
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10949 {
10950
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10951 return qe_invalid;
10952
10953
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10954 return qe_invalid;
10955
10956
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10957 return qe_invalid;
10958
10959 144 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10960 144 }
10961
10962
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10963 {
10964
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10965 return qe_invalid;
10966
10967
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10968 return qe_invalid;
10969
10970
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10971 return qe_invalid;
10972
10973 144 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10974 144 }
10975
10976
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10977 {
10978
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
10979 return qe_invalid;
10980
10981
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&flip,f))
10982 return qe_invalid;
10983
10984
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&extend,f))
10985 return qe_invalid;
10986
10987 108 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10988 108 }
10989 36 }
10990 else
10991 {
10992 memset(frozenspr, 0, sizeof(frozenspr));
10993 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10994 memset(onfirespr, 0, sizeof(onfirespr));
10995 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10996 memset(diggingspr, 0, sizeof(diggingspr));
10997 memset(usingrodspr, 0, sizeof(usingrodspr));
10998 memset(usingcanespr, 0, sizeof(usingcanespr));
10999 memset(pushingspr, 0, sizeof(pushingspr));
11000 memset(liftingspr, 0, sizeof(liftingspr));
11001 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11002 memset(stunnedspr, 0, sizeof(stunnedspr));
11003 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11004 memset(fallingspr, 0, sizeof(fallingspr));
11005 memset(shockedspr, 0, sizeof(shockedspr));
11006 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11007 memset(pullswordspr, 0, sizeof(pullswordspr));
11008 memset(readingspr, 0, sizeof(readingspr));
11009 memset(slash180spr, 0, sizeof(slash180spr));
11010 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11011 memset(dashspr, 0, sizeof(dashspr));
11012 memset(bonkspr, 0, sizeof(bonkspr));
11013 memset(medallionsprs, 0, sizeof(medallionsprs));
11014 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11015 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11016 for(int32_t q = 0; q < 4; ++q)
11017 {
11018 for(int32_t p = 0; p < 3; ++p)
11019 {
11020 drowningspr[q][p] = divespr[q][p];
11021 drowning_lavaspr[q][p] = divespr[q][p];
11022 }
11023 }
11024 }
11025
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 8)
11026 {
11027
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11028 {
11029
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11030 return qe_invalid;
11031
11032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11036 return qe_invalid;
11037
11038 144 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11039 144 }
11040 36 }
11041 else
11042 {
11043 memset(sideswimspr, 0, sizeof(sideswimspr));
11044 }
11045
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 9)
11046 {
11047
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11048 {
11049
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11050 return qe_invalid;
11051
11052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11053 return qe_invalid;
11054
11055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11056 return qe_invalid;
11057
11058 144 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11059 144 }
11060
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11061 {
11062
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11063 return qe_invalid;
11064
11065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11066 return qe_invalid;
11067
11068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11069 return qe_invalid;
11070
11071 144 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11072 144 }
11073
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11074 {
11075
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11076 return qe_invalid;
11077
11078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11079 return qe_invalid;
11080
11081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11082 return qe_invalid;
11083
11084 144 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11085 144 }
11086
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11087 {
11088
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11089 return qe_invalid;
11090
11091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11092 return qe_invalid;
11093
11094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11095 return qe_invalid;
11096
11097 144 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11098 144 }
11099 36 }
11100 else
11101 {
11102 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11103 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11104 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11105 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11106 }
11107
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 10)
11108 {
11109
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11110 {
11111 int32_t hmr;
11112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&hmr,f))
11113 return qe_invalid;
11114
11115 144 hammeroffsets[q] = hmr;
11116 144 }
11117 36 }
11118 else
11119 {
11120 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11121 }
11122
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 11)
11123 {
11124
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q)
11125 {
11126
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
11127 return qe_invalid;
11128
11129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&flip,f))
11130 return qe_invalid;
11131
11132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&extend,f))
11133 return qe_invalid;
11134
11135 108 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11136 108 }
11137 36 }
11138 else
11139 {
11140 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11141 }
11142
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 12)
11143 {
11144
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
11145 return qe_invalid;
11146
11147
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
11148 return qe_invalid;
11149
11150
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
11151 return qe_invalid;
11152 36 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11153
11154 36 }
11155 else
11156 {
11157 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11158 }
11159
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 13)
11160 {
11161
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11162 {
11163
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11164 return qe_invalid;
11165
11166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11167 return qe_invalid;
11168
11169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11170 return qe_invalid;
11171
11172 144 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11173 144 }
11174 36 }
11175 else
11176 {
11177 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11178 }
11179
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 14)
11180 {
11181
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11182 {
11183
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11184 return qe_invalid;
11185
11186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11187 return qe_invalid;
11188
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11190 return qe_invalid;
11191
11192 144 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11193 144 }
11194 36 }
11195 else
11196 {
11197 memset(revslashspr, 0, sizeof(revslashspr));
11198 }
11199
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 7)
11200 {
11201 36 int32_t num_defense = wMax;
11202 36 byte def = 0;
11203
11204 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11205 /*if(v_herosprites > [x])
11206 * {
11207 * num_defense = 146 //value of wMax on version 8
11208 * }
11209 */
11210
11211
2/2
✓ Branch 0 taken 5256 times.
✓ Branch 1 taken 36 times.
5292 for (int32_t q = 0; q < num_defense; q++)
11212 {
11213
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if (!p_getc(&def, f))
11214 return qe_invalid;
11215
11216 5256 hero_defence[q] = def;
11217 5256 }
11218 36 }
11219 else
11220 {
11221 int32_t num_defense = wMax;
11222 for (int32_t q = 0; q < num_defense; q++)
11223 {
11224 hero_defence[q] = 0;
11225 }
11226 }
11227 36 }
11228
11229
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5 times.
36 if(FFCore.quest_format[vInitData] < 34)
11230 {
11231 5 bool fastswim = zinit.hero_swim_speed > 60;
11232 // '2/3' or '1/2'
11233 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11234 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11235 5 }
11236 36 return 0;
11237 36 }
11238
11239
11240 113 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11241 {
11242 //these are here to bypass compiler warnings about unused arguments
11243 113 Header=Header;
11244
11245 dword dummy;
11246 113 word s_version=0, s_cversion=0;
11247
11248 //section version info
11249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11250 {
11251 return qe_invalid;
11252 }
11253
11254 113 FFCore.quest_format[vHeroSprites] = s_version;
11255
11256 //al_trace("Player sprites version %d\n", s_version);
11257
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11258 {
11259 return qe_invalid;
11260 }
11261
11262 //section size
11263
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11264 {
11265 return qe_invalid;
11266 }
11267
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 6 )
11268 {
11269 //al_trace("Reading Player Sprites v6\n");
11270 36 return readherosprites3(f, s_version, dummy);
11271 }
11272 77 else return readherosprites2(f, s_version, dummy);
11273 113 }
11274
11275 113 int32_t readsubscreens(PACKFILE *f, zquestheader *Header)
11276 {
11277 int32_t dummy;
11278 113 word s_version=0, s_cversion=0;
11279
11280 //section version info
11281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11282 {
11283 return qe_invalid;
11284 }
11285
11286 113 FFCore.quest_format[vSubscreen] = s_version;
11287
11288 //al_trace("Subscreens version %d\n", s_version);
11289
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11290 {
11291 return qe_invalid;
11292 }
11293
11294 //section size
11295
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11296 {
11297 return qe_invalid;
11298 }
11299
11300 //finally... section data
11301
2/2
✓ Branch 0 taken 14464 times.
✓ Branch 1 taken 113 times.
14577 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11302 {
11303 14464 int32_t ret = read_one_subscreen(f, Header, i, s_version, s_cversion);
11304
11305
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(ret!=0) return ret;
11306 14464 }
11307
11308 113 return 0;
11309 113 }
11310
11311 14464 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, int32_t i, word s_version, word)
11312 {
11313 14464 int32_t numsub=0;
11314 14464 byte temp_ss=0;
11315 subscreen_object temp_sub_stack;
11316 14464 subscreen_object *temp_sub = &temp_sub_stack;
11317
11318 char tempname[64];
11319
11320 // FWIW I never saw anything bigger than 20.
11321 #define MAX_DP1_LEN 1024
11322 char tempdp1[MAX_DP1_LEN];
11323
11324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(!pfread(tempname,64,f))
11325 {
11326 return qe_invalid;
11327 }
11328
11329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(s_version > 1)
11330 {
11331
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(!p_getc(&temp_ss,f))
11332 {
11333 return qe_invalid;
11334 }
11335 14464 }
11336
11337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(s_version < 4)
11338 {
11339 uint8_t tmp=0;
11340
11341 if(!p_getc(&tmp,f))
11342 {
11343 return qe_invalid;
11344 }
11345
11346 numsub = (int32_t)tmp;
11347 }
11348 else
11349 {
11350 word tmp;
11351
11352
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(!p_igetw(&tmp, f))
11353 {
11354 return qe_invalid;
11355 }
11356
11357 14464 numsub = (int32_t)tmp;
11358 }
11359
11360 int32_t j;
11361
11362
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42368 times.
✓ Branch 2 taken 27904 times.
✓ Branch 3 taken 14464 times.
42368 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11363 {
11364 27904 memset(temp_sub,0,sizeof(subscreen_object));
11365
11366
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 27558 times.
27904 switch(custom_subscreen[i].objects[j].type)
11367 {
11368 case ssoTEXT:
11369 case ssoTEXTBOX:
11370 case ssoCURRENTITEMTEXT:
11371 case ssoCURRENTITEMCLASSTEXT:
11372
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 346 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 346 times.
346 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11373
11374 //fall through
11375 default:
11376 27904 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11377 27904 break;
11378 }
11379
11380
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->type),f))
11381 {
11382 return qe_invalid;
11383 }
11384
11385
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->pos),f))
11386 {
11387 return qe_invalid;
11388 }
11389
11390
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(s_version < 5)
11391 {
11392 switch(temp_sub->pos)
11393 {
11394 case 0:
11395 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11396 break;
11397
11398 case 1:
11399 temp_sub->pos = sspUP;
11400 break;
11401
11402 case 2:
11403 temp_sub->pos = sspDOWN;
11404 break;
11405
11406 default:
11407 temp_sub->pos = 0;
11408 }
11409 }
11410
11411
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->x),f))
11412 {
11413 return qe_invalid;
11414 }
11415
11416
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->y),f))
11417 {
11418 return qe_invalid;
11419 }
11420
11421
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->w),f))
11422 {
11423 return qe_invalid;
11424 }
11425
11426
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->h),f))
11427 {
11428 return qe_invalid;
11429 }
11430
11431
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype1),f))
11432 {
11433 return qe_invalid;
11434 }
11435
11436
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color1),f))
11437 {
11438 return qe_invalid;
11439 }
11440
11441
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype2),f))
11442 {
11443 return qe_invalid;
11444 }
11445
11446
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color2),f))
11447 {
11448 return qe_invalid;
11449 }
11450
11451
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype3),f))
11452 {
11453 return qe_invalid;
11454 }
11455
11456
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color3),f))
11457 {
11458 return qe_invalid;
11459 }
11460
11461
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d1),f))
11462 {
11463 return qe_invalid;
11464 }
11465
11466
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d2),f))
11467 {
11468 return qe_invalid;
11469 }
11470
11471
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d3),f))
11472 {
11473 return qe_invalid;
11474 }
11475
11476
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d4),f))
11477 {
11478 return qe_invalid;
11479 }
11480
11481
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d5),f))
11482 {
11483 return qe_invalid;
11484 }
11485
11486
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d6),f))
11487 {
11488 return qe_invalid;
11489 }
11490
11491
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d7),f))
11492 {
11493 return qe_invalid;
11494 }
11495
11496
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d8),f))
11497 {
11498 return qe_invalid;
11499 }
11500
11501
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d9),f))
11502 {
11503 return qe_invalid;
11504 }
11505
11506
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d10),f))
11507 {
11508 return qe_invalid;
11509 }
11510
11511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
27904 if(s_version < 2)
11512 {
11513 if(!p_igetl(&(temp_sub->speed),f))
11514 {
11515 return qe_invalid;
11516 }
11517
11518 if(!p_igetl(&(temp_sub->delay),f))
11519 {
11520 return qe_invalid;
11521 }
11522
11523 if(!p_igetl(&(temp_sub->frame),f))
11524 {
11525 return qe_invalid;
11526 }
11527 }
11528 else
11529 {
11530
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->speed),f))
11531 {
11532 return qe_invalid;
11533 }
11534
11535
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->delay),f))
11536 {
11537 return qe_invalid;
11538 }
11539
11540
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->frame),f))
11541 {
11542 return qe_invalid;
11543 }
11544 }
11545
11546 27904 int32_t temp_size=0;
11547
11548 // bool deletets = false;
11549
4/4
✓ Branch 0 taken 11658 times.
✓ Branch 1 taken 1977 times.
✓ Branch 2 taken 14118 times.
✓ Branch 3 taken 151 times.
27904 switch(temp_sub->type)
11550 {
11551 case ssoTEXT:
11552 case ssoTEXTBOX:
11553 case ssoCURRENTITEMTEXT:
11554 case ssoCURRENTITEMCLASSTEXT:
11555 {
11556 word temptempsize;
11557
11558
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if(!p_igetw(&temptempsize,f))
11559 {
11560 return qe_invalid;
11561 }
11562
11563 //temptempsize = temp1 + (temp2 << 8);
11564 1977 temp_size = (int32_t)temptempsize;
11565
11566
11567 1977 uint32_t char_length = temp_size+2;
11568
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if (char_length > MAX_DP1_LEN)
11569 {
11570 return qe_invalid;
11571 }
11572 1977 tempdp1[char_length - 1] = '\0';
11573
11574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
1977 if(temp_size)
11575 {
11576
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if(!pfread(tempdp1,temp_size+1,f))
11577 {
11578 return qe_invalid;
11579 }
11580 1977 }
11581 }
11582 1977 break;
11583
11584 case ssoLIFEMETER:
11585
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11586 temp_sub->d3 = 1;
11587
11588
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11589 {
11590 return qe_invalid;
11591 }
11592
11593 151 break;
11594
11595
11596 case ssoCURRENTITEM:
11597
11598
1/2
✓ Branch 0 taken 11658 times.
✗ Branch 1 not taken.
11658 if(s_version < 6)
11599 {
11600 switch(temp_sub->d1)
11601 {
11602 case ssiBOMB:
11603 temp_sub->d1 = itype_bomb;
11604 break;
11605
11606 case ssiSWORD:
11607 temp_sub->d1 = itype_sword;
11608 break;
11609
11610 case ssiSHIELD:
11611 temp_sub->d1 = itype_shield;
11612 break;
11613
11614 case ssiCANDLE:
11615 temp_sub->d1 = itype_candle;
11616 break;
11617
11618 case ssiLETTER:
11619 temp_sub->d1 = itype_letter;
11620 break;
11621
11622 case ssiPOTION:
11623 temp_sub->d1 = itype_potion;
11624 break;
11625
11626 case ssiLETTERPOTION:
11627 temp_sub->d1 = itype_letterpotion;
11628 break;
11629
11630 case ssiBOW:
11631 temp_sub->d1 = itype_bow;
11632 break;
11633
11634 case ssiARROW:
11635 temp_sub->d1 = itype_arrow;
11636 break;
11637
11638 case ssiBOWANDARROW:
11639 temp_sub->d1 = itype_bowandarrow;
11640 break;
11641
11642 case ssiBAIT:
11643 temp_sub->d1 = itype_bait;
11644 break;
11645
11646 case ssiRING:
11647 temp_sub->d1 = itype_ring;
11648 break;
11649
11650 case ssiBRACELET:
11651 temp_sub->d1 = itype_bracelet;
11652 break;
11653
11654 case ssiMAP:
11655 temp_sub->d1 = itype_map;
11656 break;
11657
11658 case ssiCOMPASS:
11659 temp_sub->d1 = itype_compass;
11660 break;
11661
11662 case ssiBOSSKEY:
11663 temp_sub->d1 = itype_bosskey;
11664 break;
11665
11666 case ssiMAGICKEY:
11667 temp_sub->d1 = itype_magickey;
11668 break;
11669
11670 case ssiBRANG:
11671 temp_sub->d1 = itype_brang;
11672 break;
11673
11674 case ssiWAND:
11675 temp_sub->d1 = itype_wand;
11676 break;
11677
11678 case ssiRAFT:
11679 temp_sub->d1 = itype_raft;
11680 break;
11681
11682 case ssiLADDER:
11683 temp_sub->d1 = itype_ladder;
11684 break;
11685
11686 case ssiWHISTLE:
11687 temp_sub->d1 = itype_whistle;
11688 break;
11689
11690 case ssiBOOK:
11691 temp_sub->d1 = itype_book;
11692 break;
11693
11694 case ssiWALLET:
11695 temp_sub->d1 = itype_wallet;
11696 break;
11697
11698 case ssiSBOMB:
11699 temp_sub->d1 = itype_sbomb;
11700 break;
11701
11702 case ssiHCPIECE:
11703 temp_sub->d1 = itype_heartpiece;
11704 break;
11705
11706 case ssiAMULET:
11707 temp_sub->d1 = itype_amulet;
11708 break;
11709
11710 case ssiFLIPPERS:
11711 temp_sub->d1 = itype_flippers;
11712 break;
11713
11714 case ssiHOOKSHOT:
11715 temp_sub->d1 = itype_hookshot;
11716 break;
11717
11718 case ssiLENS:
11719 temp_sub->d1 = itype_lens;
11720 break;
11721
11722 case ssiHAMMER:
11723 temp_sub->d1 = itype_hammer;
11724 break;
11725
11726 case ssiBOOTS:
11727 temp_sub->d1 = itype_boots;
11728 break;
11729
11730 case ssiDIVINEFIRE:
11731 temp_sub->d1 = itype_divinefire;
11732 break;
11733
11734 case ssiDIVINEESCAPE:
11735 temp_sub->d1 = itype_divineescape;
11736 break;
11737
11738 case ssiDIVINEPROTECTION:
11739 temp_sub->d1 = itype_divineprotection;
11740 break;
11741
11742 case ssiQUIVER:
11743 temp_sub->d1 = itype_quiver;
11744 break;
11745
11746 case ssiBOMBBAG:
11747 temp_sub->d1 = itype_bombbag;
11748 break;
11749
11750 case ssiCBYRNA:
11751 temp_sub->d1 = itype_cbyrna;
11752 break;
11753
11754 case ssiROCS:
11755 temp_sub->d1 = itype_rocs;
11756 break;
11757
11758 case ssiHOVERBOOTS:
11759 temp_sub->d1 = itype_hoverboots;
11760 break;
11761
11762 case ssiSPINSCROLL:
11763 temp_sub->d1 = itype_spinscroll;
11764 break;
11765
11766 case ssiCROSSSCROLL:
11767 temp_sub->d1 = itype_crossscroll;
11768 break;
11769
11770 case ssiQUAKESCROLL:
11771 temp_sub->d1 = itype_quakescroll;
11772 break;
11773
11774 case ssiWHISPRING:
11775 temp_sub->d1 = itype_whispring;
11776 break;
11777
11778 case ssiCHARGERING:
11779 temp_sub->d1 = itype_chargering;
11780 break;
11781
11782 case ssiPERILSCROLL:
11783 temp_sub->d1 = itype_perilscroll;
11784 break;
11785
11786 case ssiWEALTHMEDAL:
11787 temp_sub->d1 = itype_wealthmedal;
11788 break;
11789
11790 case ssiHEARTRING:
11791 temp_sub->d1 = itype_heartring;
11792 break;
11793
11794 case ssiMAGICRING:
11795 temp_sub->d1 = itype_magicring;
11796 break;
11797
11798 case ssiSPINSCROLL2:
11799 temp_sub->d1 = itype_spinscroll2;
11800 break;
11801
11802 case ssiQUAKESCROLL2:
11803 temp_sub->d1 = itype_quakescroll2;
11804 break;
11805
11806 case ssiAGONY:
11807 temp_sub->d1 = itype_agony;
11808 break;
11809
11810 case ssiSTOMPBOOTS:
11811 temp_sub->d1 = itype_stompboots;
11812 break;
11813
11814 case ssiWHIMSICALRING:
11815 temp_sub->d1 = itype_whimsicalring;
11816 break;
11817
11818 case ssiPERILRING:
11819 temp_sub->d1 = itype_perilring;
11820 break;
11821
11822 default:
11823 temp_sub->d1 += itype_custom1 - ssiMAX;
11824 }
11825 }
11826
11827 //fall-through
11828 default:
11829
1/2
✓ Branch 0 taken 25776 times.
✗ Branch 1 not taken.
25776 if(!p_getc(&(temp_sub->dp1),f))
11830 {
11831 return qe_invalid;
11832 }
11833
11834 25776 break;
11835 }
11836
11837
2/2
✓ Branch 0 taken 19220 times.
✓ Branch 1 taken 8684 times.
27904 if(s_version < 7)
11838 {
11839
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11840 {
11841 case ssoMAGICGAUGE:
11842 {
11843
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11844 192 temp_sub->d9 = -1; //-1 now represents 'always'
11845 227 break;
11846 }
11847 case ssoLIFEGAUGE:
11848 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11849 432 break;
11850 }
11851 8684 }
11852
11853
3/3
✓ Branch 0 taken 1977 times.
✓ Branch 1 taken 24660 times.
✓ Branch 2 taken 1267 times.
27904 switch(temp_sub->type)
11854 {
11855 case ssoTEXT:
11856 case ssoTEXTBOX:
11857 case ssoCURRENTITEMTEXT:
11858 case ssoCURRENTITEMCLASSTEXT:
11859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1977 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11860
11861 1977 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11862 1977 custom_subscreen[i].objects[j].dp1 = NULL;
11863 1977 custom_subscreen[i].objects[j].dp1 = new char[temp_size+2];
11864 1977 strcpy((char*)custom_subscreen[i].objects[j].dp1,tempdp1);
11865 1977 break;
11866
11867 case ssoCOUNTER:
11868
1/2
✓ Branch 0 taken 1267 times.
✗ Branch 1 not taken.
1267 if(s_version<3)
11869 {
11870 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11871 temp_sub->d8=0;
11872 }
11873
11874 default:
11875 25927 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11876 25927 break;
11877 }
11878
11879 27904 custom_subscreen[i].name[0] = '\0';
11880 27904 strncat(custom_subscreen[i].name, tempname, 64 - 1);
11881 27904 custom_subscreen[i].ss_type = temp_ss;
11882 27904 }
11883
11884
2/2
✓ Branch 0 taken 3674880 times.
✓ Branch 1 taken 14464 times.
3689344 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11885 {
11886 //clear all unused object in this subscreen -DD
11887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3674880 times.
3674880 switch(custom_subscreen[i].objects[j].type)
11888 {
11889 case ssoTEXT:
11890 case ssoTEXTBOX:
11891 case ssoCURRENTITEMTEXT:
11892 case ssoCURRENTITEMCLASSTEXT:
11893 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11894
11895 //fall through
11896 default:
11897 3674880 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11898 3674880 break;
11899 }
11900 3674880 }
11901
11902 14464 return 0;
11903 14464 }
11904
11905 3968 void reset_subscreen(subscreen_group *tempss)
11906 {
11907
2/2
✓ Branch 0 taken 1015808 times.
✓ Branch 1 taken 3968 times.
1019776 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11908 {
11909
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1015754 times.
1015808 switch(tempss->objects[i].type)
11910 {
11911 case ssoTEXT:
11912 case ssoTEXTBOX:
11913 case ssoCURRENTITEMTEXT:
11914 case ssoCURRENTITEMCLASSTEXT:
11915
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11916
11917 //fall through
11918 default:
11919 1015808 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11920 1015808 break;
11921 }
11922 1015808 }
11923 3968 }
11924
11925 31 void reset_subscreens()
11926 {
11927
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 31 times.
3999 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11928 {
11929 3968 reset_subscreen(&custom_subscreen[i]);
11930 3968 }
11931 31 }
11932
11933 31 int32_t setupsubscreens()
11934 {
11935 31 reset_subscreens();
11936 31 int32_t tempsubscreen=zinit.subscreen;
11937 subscreen_object *tempsub;
11938
11939
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11940 {
11941 tempsubscreen=0;
11942 }
11943
11944
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11945 {
11946 case ssdtOLD:
11947 case ssdtNEWSUBSCR:
11948 case ssdtREV2:
11949 case ssdtBSZELDA:
11950 case ssdtBSZELDAMODIFIED:
11951 case ssdtBSZELDAENHANCED:
11952 case ssdtBSZELDACOMPLETE:
11953 {
11954 31 tempsub = default_subscreen_active[tempsubscreen][0];
11955 int32_t i;
11956
11957
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11958 {
11959
2/3
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1933 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11960 {
11961 case ssoTEXT:
11962 case ssoTEXTBOX:
11963 case ssoCURRENTITEMTEXT:
11964 case ssoCURRENTITEMCLASSTEXT:
11965
1/4
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
82 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11966
11967 82 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11968 82 custom_subscreen[0].objects[i].dp1 = NULL;
11969 82 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11970 82 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11971 82 break;
11972
11973 case ssoLIFEMETER:
11974 {
11975 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11976
11977 if(get_bit(deprecated_rules, 12) != 0)
11978 custom_subscreen[0].objects[i].d3=1;
11979 else
11980 custom_subscreen[0].objects[i].d3=0;
11981
11982 break;
11983 }
11984 /*
11985 case ssoTRIFRAME:
11986 {
11987 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11988 custom_subscreen[0].objects[i].d1 = 8594;
11989 custom_subscreen[0].objects[i].d2 = 8;
11990 custom_subscreen[0].objects[i].d3 = 8771;
11991 custom_subscreen[0].objects[i].d4 = 8;
11992 custom_subscreen[0].objects[i].d5 = 1;
11993 custom_subscreen[0].objects[i].d6 = 1;
11994 break;
11995 }*/
11996
11997 default:
11998 1933 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11999 1933 break;
12000 }
12001 2015 }
12002
12003 31 custom_subscreen[0].ss_type=sstACTIVE;
12004 31 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12005 31 tempsub = default_subscreen_active[tempsubscreen][1];
12006
12007
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12008 {
12009
2/3
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1920 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
12010 {
12011 case ssoTEXT:
12012 case ssoTEXTBOX:
12013 case ssoCURRENTITEMTEXT:
12014 case ssoCURRENTITEMCLASSTEXT:
12015
1/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
95 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12016
12017 95 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12018 95 custom_subscreen[1].objects[i].dp1 = NULL;
12019 95 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12020 95 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12021 95 break;
12022
12023 case ssoLIFEMETER:
12024 {
12025 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12026
12027 if(get_bit(deprecated_rules, 12) != 0)
12028 custom_subscreen[1].objects[i].d3=1;
12029 else
12030 custom_subscreen[1].objects[i].d3=0;
12031
12032 break;
12033 }
12034 /*
12035 case ssoTRIFRAME:
12036 {
12037 custom_subscreen[1].objects[i].d1 = 8594;
12038 custom_subscreen[1].objects[i].d2 = 8;
12039 custom_subscreen[1].objects[i].d3 = 8771;
12040 custom_subscreen[1].objects[i].d4 = 8;
12041 custom_subscreen[1].objects[i].d5 = 1;
12042 custom_subscreen[1].objects[i].d6 = 1;
12043 break;
12044 }*/
12045
12046 default:
12047 1920 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12048 1920 break;
12049 }
12050 2015 }
12051
12052 31 custom_subscreen[1].ss_type=sstACTIVE;
12053 31 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12054 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12055 31 tempsub = default_subscreen_passive[tempsubscreen][0];
12056
12057
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 620 times.
✓ Branch 3 taken 31 times.
651 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12058 {
12059
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 31 times.
620 switch(tempsub[i].type)
12060 {
12061 case ssoTEXT:
12062 case ssoTEXTBOX:
12063 case ssoCURRENTITEMTEXT:
12064 case ssoCURRENTITEMCLASSTEXT:
12065
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12066
12067 93 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12068 93 custom_subscreen[2].objects[i].dp1 = NULL;
12069 93 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12070 93 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12071 93 break;
12072
12073 case ssoLIFEMETER:
12074 {
12075 31 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12076
12077
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12078 14 custom_subscreen[2].objects[i].d3=1;
12079 else
12080 17 custom_subscreen[2].objects[i].d3=0;
12081
12082 31 break;
12083 }
12084
12085 default:
12086 496 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12087 496 break;
12088 }
12089 620 }
12090
12091 31 custom_subscreen[2].ss_type=sstPASSIVE;
12092 31 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12093 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12094 31 tempsub = default_subscreen_passive[tempsubscreen][1];
12095
12096
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 31 times.
620 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12097 {
12098
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 465 times.
✓ Branch 2 taken 31 times.
589 switch(tempsub[i].type)
12099 {
12100 case ssoTEXT:
12101 case ssoTEXTBOX:
12102 case ssoCURRENTITEMTEXT:
12103 case ssoCURRENTITEMCLASSTEXT:
12104
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12105
12106 93 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12107 93 custom_subscreen[3].objects[i].dp1 = NULL;
12108 93 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12109 93 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12110 93 break;
12111
12112 case ssoLIFEMETER:
12113 {
12114 31 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12115
12116
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12117 14 custom_subscreen[3].objects[i].d3=1;
12118 else
12119 17 custom_subscreen[3].objects[i].d3=0;
12120
12121 31 break;
12122 }
12123
12124 default:
12125 465 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12126 465 break;
12127 }
12128 589 }
12129
12130 31 custom_subscreen[3].ss_type=sstPASSIVE;
12131 31 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12132 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12133 31 break;
12134 }
12135
12136 case ssdtZ3:
12137 {
12138 tempsub = z3_active_a;
12139 int32_t i;
12140
12141 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12142 {
12143 switch(tempsub[i].type)
12144 {
12145 case ssoTEXT:
12146 case ssoTEXTBOX:
12147 case ssoCURRENTITEMTEXT:
12148 case ssoCURRENTITEMCLASSTEXT:
12149 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12150
12151 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12152 custom_subscreen[0].objects[i].dp1 = NULL;
12153 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12154 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12155 break;
12156
12157 case ssoLIFEMETER:
12158 {
12159 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12160
12161 if(get_bit(deprecated_rules, 12) != 0)
12162 custom_subscreen[0].objects[i].d3=1;
12163 else
12164 custom_subscreen[0].objects[i].d3=0;
12165
12166 break;
12167 }
12168
12169 default:
12170 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12171 break;
12172 }
12173 }
12174
12175 custom_subscreen[0].ss_type=sstACTIVE;
12176 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12177 tempsub = z3_active_ab;
12178
12179 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12180 {
12181 switch(tempsub[i].type)
12182 {
12183 case ssoTEXT:
12184 case ssoTEXTBOX:
12185 case ssoCURRENTITEMTEXT:
12186 case ssoCURRENTITEMCLASSTEXT:
12187 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12188
12189 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12190 custom_subscreen[1].objects[i].dp1 = NULL;
12191 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12192 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12193 break;
12194
12195 case ssoLIFEMETER:
12196 {
12197 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12198
12199 if(get_bit(deprecated_rules, 12) != 0)
12200 custom_subscreen[1].objects[i].d3=1;
12201 else
12202 custom_subscreen[1].objects[i].d3=0;
12203
12204 break;
12205 }
12206
12207 default:
12208 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12209 break;
12210 }
12211 }
12212
12213 custom_subscreen[1].ss_type=sstACTIVE;
12214 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12215 tempsub = z3_passive_a;
12216
12217 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12218 {
12219 switch(tempsub[i].type)
12220 {
12221 case ssoTEXT:
12222 case ssoTEXTBOX:
12223 case ssoCURRENTITEMTEXT:
12224 case ssoCURRENTITEMCLASSTEXT:
12225 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12226
12227 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12228 custom_subscreen[2].objects[i].dp1 = NULL;
12229 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12230 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12231 break;
12232
12233 case ssoLIFEMETER:
12234 {
12235 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12236
12237 if(get_bit(deprecated_rules, 12) != 0)
12238 custom_subscreen[2].objects[i].d3=1;
12239 else
12240 custom_subscreen[2].objects[i].d3=0;
12241
12242 break;
12243 }
12244
12245 default:
12246 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12247 break;
12248 }
12249 }
12250
12251 custom_subscreen[2].ss_type=sstPASSIVE;
12252 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12253 tempsub = z3_passive_ab;
12254
12255 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12256 {
12257 switch(tempsub[i].type)
12258 {
12259 case ssoTEXT:
12260 case ssoTEXTBOX:
12261 case ssoCURRENTITEMTEXT:
12262 case ssoCURRENTITEMCLASSTEXT:
12263 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12264
12265 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12266 custom_subscreen[3].objects[i].dp1 = NULL;
12267 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12268 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12269 break;
12270
12271 case ssoLIFEMETER:
12272 {
12273 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12274
12275 if(get_bit(deprecated_rules, 12) != 0)
12276 custom_subscreen[3].objects[i].d3=1;
12277 else
12278 custom_subscreen[3].objects[i].d3=0;
12279
12280 break;
12281 }
12282
12283 default:
12284 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12285 break;
12286 }
12287 }
12288
12289 custom_subscreen[3].ss_type=sstPASSIVE;
12290 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12291 break;
12292 }
12293 }
12294
12295
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 124 times.
155 for(int32_t i=0; i<4; ++i)
12296 {
12297 124 purge_blank_subscreen_objects(&custom_subscreen[i]);
12298 124 }
12299
12300 31 return 0;
12301 }
12302
12303 extern script_data *ffscripts[NUMSCRIPTFFC];
12304 extern script_data *itemscripts[NUMSCRIPTITEM];
12305 extern script_data *guyscripts[NUMSCRIPTGUYS];
12306 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12307 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12308 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12309 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12310 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12311 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12312 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12313 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12314 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12315 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12316 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12317
12318
12319
12320 107 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12321 {
12322 int32_t dummy;
12323 107 word s_version=0, s_cversion=0, zmeta_version=0;
12324 107 byte numscripts=0;
12325 107 numscripts=numscripts; //to avoid unused variables warnings
12326 int32_t ret;
12327
12328 //section version info
12329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if(!p_igetw(&s_version,f))
12330 {
12331 return qe_invalid;
12332 }
12333
12334 107 FFCore.quest_format[vFFScript] = s_version;
12335
12336
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetw(&s_cversion,f))
12337 {
12338 return qe_invalid;
12339 }
12340
12341
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 36 times.
107 if(s_version >= 18)
12342 {
12343
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&zmeta_version,f))
12344 {
12345 return qe_invalid;
12346 }
12347 36 }
12348
12349 //al_trace("Scripts version %d\n", s_version);
12350 //section size
12351
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(!p_igetl(&dummy,f))
12352 {
12353 return qe_invalid;
12354 }
12355
12356 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12357 107 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12358 107 temp_ffscript_version = s_version;
12359 //miscQdata *the_misc;
12360
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 77 times.
107 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12361 107 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12362
12363 //finally... section data
12364
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 55 times.
57963 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12365 {
12366 57856 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12367
12368
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if (ret)
12369 {
12370 return qe_invalid;
12371 }
12372 57856 }
12373
12374 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12375 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12376 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12377 * there was a version bump a week before a change that broke stuff.
12378 */
12379
7/8
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 36 times.
55 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12380 {
12381 91 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12382 91 }
12383
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 19)
12384 {
12385 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12386 77 }
12387
12388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 1)
12389 {
12390
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12391 {
12392 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12393
12394
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12395 {
12396 return qe_invalid;
12397 }
12398 28928 }
12399
12400
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12401 {
12402 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12403
12404
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12405 {
12406 return qe_invalid;
12407 }
12408 28928 }
12409
12410
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12411 {
12412 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12413
12414
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12415 {
12416 return qe_invalid;
12417 }
12418 28928 }
12419
12420
12421
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12422 {
12423 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12424
12425
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12426 {
12427 return qe_invalid;
12428 }
12429 28928 }
12430
12431
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 16)
12432 {
12433
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 36 times.
324 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12434 {
12435 288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12436
12437
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if (ret)
12438 {
12439 return qe_invalid;
12440 }
12441 288 }
12442 36 }
12443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12444 {
12445 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12446 {
12447 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12448
12449 if (ret)
12450 {
12451 return qe_invalid;
12452 }
12453 }
12454
12455 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12456 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12457
12458 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12459 }
12460
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12461 {
12462
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12463 {
12464 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12465
12466
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12467 {
12468 return qe_invalid;
12469 }
12470 308 }
12471
12472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12473
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12474
12475
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12476
12477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12478
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12479
12480
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12481
12482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12483
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12484
12485
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12486
12487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12488
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12489
12490
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12491 77 }
12492 else
12493 {
12494 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12495 {
12496 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12497
12498 if (ret)
12499 {
12500 return qe_invalid;
12501 }
12502 }
12503
12504 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12505 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12506
12507 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12508
12509 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12510 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12511
12512 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12513
12514 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12515 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12516
12517 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12518
12519 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12520 delete globalscripts[GLOBAL_SCRIPT_F6];
12521
12522 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12523
12524 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12525 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12526
12527 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12528 }
12529
12530
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 10) //expanded the number of Player scripts to 5.
12531 {
12532
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 36 times.
216 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12533 {
12534 180 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12535
12536
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (ret)
12537 {
12538 return qe_invalid;
12539 }
12540 180 }
12541 36 }
12542 else
12543 {
12544
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12545 {
12546 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12547
12548
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12549 {
12550 return qe_invalid;
12551 }
12552 231 }
12553
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12554
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12555
12556
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12557
12558
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12560
12561
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12562 }
12563
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
113 if(s_version > 8 && s_version < 10)
12564 {
12565
12566 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12567 {
12568 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12569
12570 if (ret)
12571 {
12572 return qe_invalid;
12573 }
12574 }
12575 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12576 {
12577 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12578
12579 if (ret)
12580 {
12581 return qe_invalid;
12582 }
12583 }
12584
12585 }
12586
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 10)
12587 {
12588
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12589 {
12590 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12591
12592
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12593 {
12594 return qe_invalid;
12595 }
12596 9216 }
12597
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12598 {
12599 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12600
12601
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12602 {
12603 return qe_invalid;
12604 }
12605 9216 }
12606
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12607 {
12608 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12609
12610
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12611 {
12612 return qe_invalid;
12613 }
12614 9216 }
12615
12616 36 }
12617
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=12)
12618 {
12619
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12620 {
12621 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12622
12623
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12624 {
12625 return qe_invalid;
12626 }
12627 9216 }
12628 36 }
12629
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=15)
12630 {
12631
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12632 {
12633 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12634
12635
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12636 {
12637 return qe_invalid;
12638 }
12639 18432 }
12640 36 }
12641
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >19)
12642 {
12643 36 word numgenscripts = NUMSCRIPTSGENERIC;
12644
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&numgenscripts,f))
12645 {
12646 return qe_invalid;
12647 }
12648
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < numgenscripts; i++)
12649 {
12650 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12651
12652
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12653 {
12654 return qe_invalid;
12655 }
12656 18432 }
12657 36 }
12658
12659 /*
12660 else //Is this trip really necessary?
12661 {
12662 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12663 {
12664
12665 ewpnscripts[i] = NULL;
12666 }
12667 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12668 {
12669 dmapscripts[i] = NULL;
12670 }
12671 }
12672 */
12673
12674 113 }
12675
12676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 2)
12677 {
12678 int32_t bufsize;
12679 113 p_igetl(&bufsize, f);
12680
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
113 if (bufsize < 0 || bufsize > 1024*1024*10)
12681 {
12682 // God help anyone storing more than 10MB of code in the script buffer.
12683 return qe_invalid;
12684 }
12685 113 char * buf = new char[bufsize+1];
12686 113 pfread(buf, bufsize, f);
12687 113 buf[bufsize]=0;
12688
12689
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 zScript = string(buf);
12690
12691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 delete[] buf;
12692 word numffcbindings;
12693 113 p_igetw(&numffcbindings, f);
12694
12695
2/2
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 113 times.
1692 for(int32_t i=0; i<numffcbindings; i++)
12696 {
12697 word id;
12698 1579 p_igetw(&id, f);
12699 1579 p_igetl(&bufsize, f);
12700
2/4
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1579 times.
1579 if (bufsize < 0 || bufsize > 1024)
12701 return qe_invalid;
12702 1579 buf = new char[bufsize+1];
12703 1579 pfread(buf, bufsize, f);
12704 1579 buf[bufsize]=0;
12705
12706 //fix for buggy older saved quests -DD
12707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 if(id < NUMSCRIPTFFC-1)
12708 1579 ffcmap[id].scriptname = buf;
12709
12710
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 delete[] buf;
12711 1579 }
12712
12713 word numglobalbindings;
12714 113 p_igetw(&numglobalbindings, f);
12715
12716
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 113 times.
550 for(int32_t i=0; i<numglobalbindings; i++)
12717 {
12718 word id;
12719 437 p_igetw(&id, f);
12720 437 p_igetl(&bufsize, f);
12721
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12722 return qe_invalid;
12723 437 buf = new char[bufsize+1];
12724 437 pfread(buf, bufsize, f);
12725 437 buf[bufsize]=0;
12726
12727 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12728 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12729 // Ignore these. -DD
12730
3/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 278 times.
437 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12731 {
12732 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12733
1/2
✓ Branch 0 taken 278 times.
✗ Branch 1 not taken.
278 if(strcmp(buf,"~Continue") == 0)
12734 {
12735 globalmap[id].scriptname = "";
12736
12737 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12738 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12739 }
12740 else
12741 {
12742 278 globalmap[id].scriptname = buf;
12743 }
12744 278 }
12745
12746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12747 437 }
12748
12749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 3)
12750 {
12751 word numitembindings;
12752 113 p_igetw(&numitembindings, f);
12753
12754
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 113 times.
211 for(int32_t i=0; i<numitembindings; i++)
12755 {
12756 word id;
12757 98 p_igetw(&id, f);
12758 98 p_igetl(&bufsize, f);
12759
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
98 if (bufsize < 0 || bufsize > 1024)
12760 return qe_invalid;
12761 98 buf = new char[bufsize+1];
12762 98 pfread(buf, bufsize, f);
12763 98 buf[bufsize]=0;
12764
12765 //fix this too
12766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12767 98 itemmap[id].scriptname = buf;
12768
12769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12770 98 }
12771 113 }
12772 //(v9+)
12773
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 8)
12774 {
12775 //npc scripts
12776 word numnpcbindings;
12777 36 p_igetw(&numnpcbindings, f);
12778
12779
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
48 for(int32_t i=0; i<numnpcbindings; i++)
12780 {
12781 word id;
12782 12 p_igetw(&id, f);
12783 12 p_igetl(&bufsize, f);
12784
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12785 return qe_invalid;
12786 12 buf = new char[bufsize+1];
12787 12 pfread(buf, bufsize, f);
12788 12 buf[bufsize]=0;
12789
12790 //fix this too
12791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12792 12 npcmap[id].scriptname = buf;
12793
12794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12795 12 }
12796 //lweapon
12797 word numlwpnbindings;
12798 36 p_igetw(&numlwpnbindings, f);
12799
12800
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 36 times.
78 for(int32_t i=0; i<numlwpnbindings; i++)
12801 {
12802 word id;
12803 42 p_igetw(&id, f);
12804 42 p_igetl(&bufsize, f);
12805
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if (bufsize < 0 || bufsize > 1024)
12806 return qe_invalid;
12807 42 buf = new char[bufsize+1];
12808 42 pfread(buf, bufsize, f);
12809 42 buf[bufsize]=0;
12810
12811 //fix this too
12812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12813 42 lwpnmap[id].scriptname = buf;
12814
12815
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 delete[] buf;
12816 42 }
12817 //eweapon
12818 word numewpnbindings;
12819 36 p_igetw(&numewpnbindings, f);
12820
12821
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 36 times.
99 for(int32_t i=0; i<numewpnbindings; i++)
12822 {
12823 word id;
12824 63 p_igetw(&id, f);
12825 63 p_igetl(&bufsize, f);
12826
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12827 return qe_invalid;
12828 63 buf = new char[bufsize+1];
12829 63 pfread(buf, bufsize, f);
12830 63 buf[bufsize]=0;
12831
12832 //fix this too
12833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12834 63 ewpnmap[id].scriptname = buf;
12835
12836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12837 63 }
12838 //hero
12839 word numherobindings;
12840 36 p_igetw(&numherobindings, f);
12841
12842
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 36 times.
41 for(int32_t i=0; i<numherobindings; i++)
12843 {
12844 word id;
12845 5 p_igetw(&id, f);
12846 5 p_igetl(&bufsize, f);
12847
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if (bufsize < 0 || bufsize > 1024)
12848 return qe_invalid;
12849 5 buf = new char[bufsize+1];
12850 5 pfread(buf, bufsize, f);
12851 5 buf[bufsize]=0;
12852
12853 //fix this too
12854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12855 5 playermap[id].scriptname = buf;
12856
12857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12858 5 }
12859 //dmaps
12860 word numdmapbindings;
12861 36 p_igetw(&numdmapbindings, f);
12862
12863
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 36 times.
69 for(int32_t i=0; i<numdmapbindings; i++)
12864 {
12865 word id;
12866 33 p_igetw(&id, f);
12867 33 p_igetl(&bufsize, f);
12868
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if (bufsize < 0 || bufsize > 1024)
12869 return qe_invalid;
12870 33 buf = new char[bufsize+1];
12871 33 pfread(buf, bufsize, f);
12872 33 buf[bufsize]=0;
12873
12874 //fix this too
12875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(id <NUMSCRIPTSDMAP-1)
12876 33 dmapmap[id].scriptname = buf;
12877
12878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 delete[] buf;
12879 33 }
12880 //screen
12881 word numscreenbindings;
12882 36 p_igetw(&numscreenbindings, f);
12883
12884
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 36 times.
73 for(int32_t i=0; i<numscreenbindings; i++)
12885 {
12886 word id;
12887 37 p_igetw(&id, f);
12888 37 p_igetl(&bufsize, f);
12889
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if (bufsize < 0 || bufsize > 1024)
12890 return qe_invalid;
12891 37 buf = new char[bufsize+1];
12892 37 pfread(buf, bufsize, f);
12893 37 buf[bufsize]=0;
12894
12895 //fix this too
12896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(id <NUMSCRIPTSDMAP-1)
12897 37 screenmap[id].scriptname = buf;
12898
12899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 delete[] buf;
12900 37 }
12901 36 }
12902
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 11)
12903 {
12904 word numspritebindings;
12905 36 p_igetw(&numspritebindings, f);
12906
12907
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36 times.
46 for(int32_t i=0; i<numspritebindings; i++)
12908 {
12909 word id;
12910 10 p_igetw(&id, f);
12911 10 p_igetl(&bufsize, f);
12912
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if (bufsize < 0 || bufsize > 1024)
12913 return qe_invalid;
12914 10 buf = new char[bufsize+1];
12915 10 pfread(buf, bufsize, f);
12916 10 buf[bufsize]=0;
12917
12918 //fix this too
12919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12920 10 itemspritemap[id].scriptname = buf;
12921
12922
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 delete[] buf;
12923 10 }
12924 36 }
12925
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 15)
12926 {
12927 word numcombobindings;
12928 36 p_igetw(&numcombobindings, f);
12929
12930
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 36 times.
59 for(int32_t i=0; i<numcombobindings; i++)
12931 {
12932 word id;
12933 23 p_igetw(&id, f);
12934 23 p_igetl(&bufsize, f);
12935
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12936 return qe_invalid;
12937 23 buf = new char[bufsize+1];
12938 23 pfread(buf, bufsize, f);
12939 23 buf[bufsize]=0;
12940
12941 //fix this too
12942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12943 23 comboscriptmap[id].scriptname = buf;
12944
12945
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12946 23 }
12947 36 }
12948
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 19)
12949 {
12950 word numgenericbindings;
12951 36 p_igetw(&numgenericbindings, f);
12952
12953
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 36 times.
49 for(int32_t i=0; i<numgenericbindings; i++)
12954 {
12955 word id;
12956 13 p_igetw(&id, f);
12957 13 p_igetl(&bufsize, f);
12958
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
12959 return qe_invalid;
12960 13 buf = new char[bufsize+1];
12961 13 pfread(buf, bufsize, f);
12962 13 buf[bufsize]=0;
12963
12964 //fix this too
12965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12966 13 genericmap[id].scriptname = buf;
12967
12968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12969 13 }
12970 36 }
12971 113 }
12972
12973 113 return 0;
12974 113 }
12975
12976 129 void reset_scripts()
12977 {
12978 #ifdef IS_PLAYER
12979 // We can't modify the script data while jit threads are possibly compiling them.
12980 void jit_shutdown();
12981 129 jit_shutdown();
12982 #endif
12983
12984 129 next_script_data_debug_id = 0;
12985
12986
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12987 {
12988
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 59392 times.
66048 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12989
1/2
✓ Branch 0 taken 59392 times.
✗ Branch 1 not taken.
59392 else genericscripts[i] = new script_data();
12990 66048 }
12991
12992
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12993 {
12994
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(ffscripts[i]!=NULL)
12995 {
12996 66048 ffscripts[i]->disable();
12997 66048 }
12998 else
12999 {
13000 ffscripts[i] = new script_data();
13001 }
13002 66048 }
13003
13004
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13005 {
13006
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemscripts[i]!=NULL)
13007 {
13008 33024 itemscripts[i]->disable();
13009 33024 }
13010 else
13011 {
13012 itemscripts[i] = new script_data();
13013 }
13014 33024 }
13015
13016
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13017 {
13018
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(guyscripts[i]!=NULL)
13019 {
13020 33024 guyscripts[i]->disable();
13021 33024 }
13022 else
13023 {
13024 guyscripts[i] = new script_data();
13025 }
13026 33024 }
13027
13028
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13029 {
13030
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(wpnscripts[i]!=NULL)
13031 {
13032 33024 wpnscripts[i]->disable();
13033 33024 }
13034 else
13035 {
13036 wpnscripts[i] = new script_data();
13037 }
13038 33024 }
13039
13040
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13041 {
13042
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(screenscripts[i]!=NULL)
13043 {
13044 33024 screenscripts[i]->disable();
13045 33024 }
13046 else
13047 {
13048 screenscripts[i] = new script_data();
13049 }
13050 33024 }
13051
13052
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13053 {
13054
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(globalscripts[i]!=NULL)
13055 {
13056 1032 globalscripts[i]->disable();
13057 1032 }
13058 else
13059 {
13060 globalscripts[i] = new script_data();
13061 }
13062 1032 }
13063
13064
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 129 times.
774 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13065 {
13066
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(playerscripts[i]!=NULL)
13067 {
13068 645 playerscripts[i]->disable();
13069 645 }
13070 else
13071 {
13072 playerscripts[i] = new script_data();
13073 }
13074 645 }
13075
13076
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13077 {
13078
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(lwpnscripts[i]!=NULL)
13079 {
13080 33024 lwpnscripts[i]->disable();
13081 33024 }
13082 else
13083 {
13084 lwpnscripts[i] = new script_data();
13085 }
13086 33024 }
13087
13088
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13089 {
13090
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(ewpnscripts[i]!=NULL)
13091 {
13092 33024 ewpnscripts[i]->disable();
13093 33024 }
13094 else
13095 {
13096 ewpnscripts[i] = new script_data();
13097 }
13098 33024 }
13099
13100
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13101 {
13102
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(dmapscripts[i]!=NULL)
13103 {
13104 33024 dmapscripts[i]->disable();
13105 33024 }
13106 else
13107 {
13108 dmapscripts[i] = new script_data();
13109 }
13110 33024 }
13111
13112
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13113 {
13114
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemspritescripts[i]!=NULL)
13115 {
13116 33024 itemspritescripts[i]->disable();
13117 33024 }
13118 else
13119 {
13120 itemspritescripts[i] = new script_data();
13121 }
13122 33024 }
13123
13124
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13125 {
13126
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(comboscripts[i]!=NULL)
13127 {
13128 66048 comboscripts[i]->disable();
13129 66048 }
13130 else
13131 {
13132 comboscripts[i] = new script_data();
13133 }
13134 66048 }
13135 129 }
13136
13137 extern script_command command_list[];
13138 248303 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
13139 {
13140 //Please also update loadquest() when modifying this method -DD
13141 248303 char b33[34] = {0};
13142 248303 b33[33] = 0;
13143 248303 ffscript temp_script;
13144 248303 int32_t num_commands=1000;
13145
13146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 if(s_version>=2)
13147 {
13148
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 if(!p_igetl(&num_commands,f))
13149 {
13150 return qe_invalid;
13151 }
13152 248303 }
13153
13154 #ifdef ZC_FUZZ
13155 const int32_t command_limit = 300000;
13156 #else
13157 248303 const int32_t command_limit = 10000000;
13158 #endif
13159
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 if (num_commands < 0 || num_commands > command_limit)
13160 {
13161 return qe_invalid;
13162 }
13163
13164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 if((*script) != NULL)
13165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 delete (*script);
13166
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 (*script) = new script_data(num_commands);
13167
13168
2/2
✓ Branch 0 taken 129492 times.
✓ Branch 1 taken 118811 times.
248303 if(s_version >= 16)
13169 {
13170
1/2
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
129492 zasm_meta temp_meta;
13171
13172
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.zasm_v),f))
13173 {
13174 return qe_invalid;
13175 }
13176
13177
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.meta_v),f))
13178 {
13179 return qe_invalid;
13180 }
13181
13182
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.ffscript_v),f))
13183 {
13184 return qe_invalid;
13185 }
13186
13187
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_getc(&(temp_meta.script_type),f))
13188 {
13189 return qe_invalid;
13190 }
13191
13192
2/2
✓ Branch 0 taken 1035936 times.
✓ Branch 1 taken 129492 times.
1165428 for(int32_t q = 0; q < 8; ++q)
13193 {
13194
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 978384 times.
1035936 if(zmeta_version < 3)
13195 {
13196
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13197 {
13198
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
13199 {
13200 return qe_invalid;
13201 }
13202 1899216 }
13203
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13204 57552 }
13205 else
13206 {
13207
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.run_idens[q],f))
13208 {
13209 return qe_invalid;
13210 }
13211 }
13212 1035936 }
13213
13214
2/2
✓ Branch 0 taken 129492 times.
✓ Branch 1 taken 1035936 times.
1165428 for(int32_t q = 0; q < 8; ++q)
13215 {
13216
2/4
✓ Branch 0 taken 1035936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1035936 times.
✗ Branch 3 not taken.
1035936 if(!p_getc(&(temp_meta.run_types[q]),f))
13217 {
13218 return qe_invalid;
13219 }
13220 1035936 }
13221
13222
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_getc(&(temp_meta.flags),f))
13223 {
13224 return qe_invalid;
13225 }
13226
13227
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v1),f))
13228 {
13229 return qe_invalid;
13230 }
13231
13232
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v2),f))
13233 {
13234 return qe_invalid;
13235 }
13236
13237
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v3),f))
13238 {
13239 return qe_invalid;
13240 }
13241
13242
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v4),f))
13243 {
13244 return qe_invalid;
13245 }
13246
13247
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 122298 times.
129492 if(zmeta_version == 2)
13248 {
13249
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13250 {
13251
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13252 {
13253 return qe_invalid;
13254 }
13255 237402 }
13256
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13257
13258
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13259 {
13260
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13261 {
13262 return qe_invalid;
13263 }
13264 237402 }
13265
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13266 7194 }
13267
1/2
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
122298 else if(zmeta_version > 2)
13268 {
13269
2/4
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122298 times.
✗ Branch 3 not taken.
122298 if(!p_getcstr(&temp_meta.script_name,f))
13270 return qe_invalid;
13271
2/4
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122298 times.
✗ Branch 3 not taken.
122298 if(!p_getcstr(&temp_meta.author,f))
13272 return qe_invalid;
13273 122298 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13274
2/2
✓ Branch 0 taken 1222980 times.
✓ Branch 1 taken 122298 times.
1345278 for(auto q = 0; q < num_meta_attrib; ++q)
13275 {
13276
2/4
✓ Branch 0 taken 1222980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1222980 times.
✗ Branch 3 not taken.
1222980 if(!p_getcstr(&temp_meta.attributes[q],f))
13277 return qe_invalid;
13278
2/4
✓ Branch 0 taken 1222980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1222980 times.
✗ Branch 3 not taken.
1222980 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13279 return qe_invalid;
13280 1222980 }
13281
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13282 {
13283
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.attribytes[q],f))
13284 return qe_invalid;
13285
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13286 return qe_invalid;
13287 978384 }
13288
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13289 {
13290
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13291 return qe_invalid;
13292
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13293 return qe_invalid;
13294 978384 }
13295
2/2
✓ Branch 0 taken 1956768 times.
✓ Branch 1 taken 122298 times.
2079066 for(auto q = 0; q < 16; ++q)
13296 {
13297
2/4
✓ Branch 0 taken 1956768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1956768 times.
✗ Branch 3 not taken.
1956768 if(!p_getcstr(&temp_meta.usrflags[q],f))
13298 return qe_invalid;
13299
2/4
✓ Branch 0 taken 1956768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1956768 times.
✗ Branch 3 not taken.
1956768 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13300 return qe_invalid;
13301 1956768 }
13302 122298 }
13303
2/2
✓ Branch 0 taken 122298 times.
✓ Branch 1 taken 7194 times.
129492 if(zmeta_version > 3)
13304 {
13305
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13306 {
13307
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.initd[q],f))
13308 return qe_invalid;
13309
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.initd_help[q],f))
13310 return qe_invalid;
13311 978384 }
13312
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13313 {
13314
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getc(&temp_meta.initd_type[q],f))
13315 return qe_invalid;
13316 978384 }
13317 122298 }
13318 else
13319 {
13320
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13321 {
13322
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13323 57552 }
13324 }
13325
13326
1/2
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
129492 (*script)->meta = temp_meta;
13327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129492 times.
129492 }
13328
13329
1/2
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
248303 temp_script.clear();
13330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21826437 times.
21826437 for(int32_t j=0; j<num_commands; j++)
13331 {
13332
2/4
✓ Branch 0 taken 21826437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21826437 times.
✗ Branch 3 not taken.
21826437 if(!p_igetw(&(temp_script.command),f))
13333 {
13334 return qe_invalid;
13335 }
13336
13337
2/2
✓ Branch 0 taken 248303 times.
✓ Branch 1 taken 21578134 times.
21826437 if(temp_script.command == 0xFFFF)
13338 {
13339
1/2
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
248303 (*script)->zasm[j].clear();
13340 248303 break;
13341 }
13342 else
13343 {
13344
2/4
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21578134 times.
✗ Branch 3 not taken.
21578134 if(!p_igetl(&(temp_script.arg1),f))
13345 {
13346 return qe_invalid;
13347 }
13348
13349
2/4
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21578134 times.
✗ Branch 3 not taken.
21578134 if(!p_igetl(&(temp_script.arg2),f))
13350 {
13351 return qe_invalid;
13352 }
13353
13354
2/2
✓ Branch 0 taken 905513 times.
✓ Branch 1 taken 20672621 times.
21578134 if(s_version >= 21)
13355 {
13356 905513 uint32_t sz = 0;
13357
2/4
✓ Branch 0 taken 905513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 905513 times.
✗ Branch 3 not taken.
905513 if(!p_igetl(&sz,f))
13358 {
13359 return qe_invalid;
13360 }
13361
2/2
✓ Branch 0 taken 3202 times.
✓ Branch 1 taken 902311 times.
905513 if(sz) //string found
13362 {
13363
1/2
✓ Branch 0 taken 3202 times.
✗ Branch 1 not taken.
3202 temp_script.strptr = new std::string();
13364 char dummy;
13365
2/2
✓ Branch 0 taken 232733 times.
✓ Branch 1 taken 3202 times.
235935 for(size_t q = 0; q < sz; ++q)
13366 {
13367
2/4
✓ Branch 0 taken 232733 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232733 times.
✗ Branch 3 not taken.
232733 if(!p_getc(&dummy,f))
13368 {
13369 return qe_invalid;
13370 }
13371
1/2
✓ Branch 0 taken 232733 times.
✗ Branch 1 not taken.
232733 temp_script.strptr->push_back(dummy);
13372 232733 }
13373 3202 }
13374
2/4
✓ Branch 0 taken 905513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 905513 times.
✗ Branch 3 not taken.
905513 if(!p_igetl(&sz,f))
13375 {
13376 return qe_invalid;
13377 }
13378
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 905412 times.
905513 if(sz) //vector found
13379 {
13380
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13381 int32_t dummy;
13382
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13383 {
13384
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
13385 {
13386 return qe_invalid;
13387 }
13388
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13389 1487 }
13390 101 }
13391 905513 }
13392
13393
1/2
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
21578134 temp_script.give((*script)->zasm[j]);
13394 }
13395
1/2
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
21578134 temp_script.clear();
13396 21578134 }
13397
13398 248303 return 0;
13399 248303 }
13400
13401 extern SAMPLE customsfxdata[WAV_COUNT];
13402 extern uint8_t customsfxflag[WAV_COUNT>>3];
13403 extern int32_t sfxdat;
13404 extern DATAFILE *sfxdata;
13405 const char *old_sfx_string[Z35] =
13406 {
13407 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13408 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13409 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13410 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13411 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13412 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13413 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13414 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13415 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13416 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13417 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13418 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13419 };
13420 char *sfx_string[WAV_COUNT];
13421
13422 113 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13423 {
13424 //these are here to bypass compiler warnings about unused arguments
13425 113 Header=Header;
13426
13427 int32_t dummy;
13428 113 word s_version=0, s_cversion=0;
13429 //int32_t ret;
13430 SAMPLE temp_sample;
13431 113 temp_sample.loop_start=0;
13432 113 temp_sample.loop_end=0;
13433 113 temp_sample.param=0;
13434
13435 //section version info
13436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
13437 {
13438 return qe_invalid;
13439 }
13440
13441 113 FFCore.quest_format[vSFX] = s_version;
13442
13443 //al_trace("SFX version %d\n", s_version);
13444
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
13445 {
13446 return qe_invalid;
13447 }
13448
13449 //section size
13450
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
13451 {
13452 return qe_invalid;
13453 }
13454
13455 /* HIGHLY UNORTHODOX UPDATING THING, by L
13456 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13457 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13458 * changing from 1 to 2.
13459 */
13460
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 2)
13461 set_qr(qr_GOTOLESSNOTEQUAL,1);
13462
13463 /* End highly unorthodox updating thing */
13464
13465 113 int32_t wavcount = WAV_COUNT;
13466
13467
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13468 wavcount = 128;
13469
13470 uint8_t tempflag[WAV_COUNT>>3];
13471
13472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 4)
13473 {
13474 memset(tempflag, 0xFF, WAV_COUNT>>3);
13475 }
13476 else
13477 {
13478
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13479 memset(tempflag, 0, WAV_COUNT>>3);
13480
13481
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 113 times.
3729 for(int32_t i=0; i<(wavcount>>3); i++)
13482 {
13483 3616 p_getc(&tempflag[i], f);
13484 3616 }
13485
13486 }
13487
13488
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version>4)
13489 {
13490
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<WAV_COUNT; i++)
13491 {
13492 28815 sprintf(sfx_string[i],"s%03d",i);
13493
13494
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 6780 times.
28815 if((i<Z35))
13495 6780 strcpy(sfx_string[i], old_sfx_string[i-1]);
13496
13497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28815 times.
28815 if(i>=wavcount)
13498 continue;
13499
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 25743 times.
28815 if(get_bit(tempflag, i-1))
13500 {
13501 char tempname[36];
13502
13503
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!pfread(tempname, 36, f))
13504 {
13505 return qe_invalid;
13506 }
13507
13508 3072 sfx_string[i][0] = '\0';
13509 3072 strncat(sfx_string[i], tempname, 36 - 1);
13510 3072 }
13511 else
13512 {
13513 25743 sprintf(sfx_string[i],"s%03d",i);
13514
13515
2/2
✓ Branch 0 taken 21165 times.
✓ Branch 1 taken 4578 times.
25743 if(i<Z35)
13516 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13517 25743 sfx_string[i][35] = 0; //Force NULL Termination
13518 }
13519 28815 }
13520 113 }
13521 else
13522 {
13523 for(int32_t i=1; i<WAV_COUNT; i++)
13524 {
13525 sprintf(sfx_string[i],"s%03d",i);
13526
13527 if(i<Z35)
13528 strcpy(sfx_string[i], old_sfx_string[i-1]);
13529 }
13530 }
13531
13532 //finally... section data
13533
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<wavcount; i++)
13534 {
13535
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 25743 times.
28815 if(get_bit(tempflag, i-1))
13536 {
13537
13538
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13539 {
13540 return qe_invalid;
13541 }
13542
13543 3072 (temp_sample.bits) = dummy;
13544
13545
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13546 {
13547 return qe_invalid;
13548 }
13549
13550 3072 (temp_sample.stereo) = dummy;
13551
13552
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13553 {
13554 return qe_invalid;
13555 }
13556
13557 3072 (temp_sample.freq) = dummy;
13558
13559
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13560 {
13561 return qe_invalid;
13562 }
13563
13564 3072 (temp_sample.priority) = dummy;
13565
13566
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.len),f))
13567 {
13568 return qe_invalid;
13569 }
13570
13571
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.loop_start),f))
13572 {
13573 return qe_invalid;
13574 }
13575
13576
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.loop_end),f))
13577 {
13578 return qe_invalid;
13579 }
13580
13581
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.param),f))
13582 {
13583 return qe_invalid;
13584 }
13585
13586 // al_trace("F%i: L%i\n",i,temp_sample.len);
13587 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13588 3072 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13589
2/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3072 times.
3072 if (len < 0 || len > 10000000)
13590 {
13591 return qe_invalid;
13592 }
13593 3072 temp_sample.data = calloc(len,1);
13594
13595
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(s_version < 3)
13596 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13597
13598 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 if(s_version < 2)
13600 {
13601 if(!pfread(temp_sample.data, len,f))
13602 {
13603 return qe_invalid;
13604 }
13605 }
13606 else
13607 {
13608 //re-endianfy the data
13609 3072 int32_t wordstoread = len / sizeof(word);
13610
13611
2/2
✓ Branch 0 taken 89161498 times.
✓ Branch 1 taken 3072 times.
89164570 for(int32_t j=0; j<wordstoread; j++)
13612 {
13613 word temp;
13614
13615
1/2
✓ Branch 0 taken 89161498 times.
✗ Branch 1 not taken.
89161498 if(!p_igetw(&temp, f))
13616 {
13617 return qe_invalid;
13618 }
13619
13620 89161498 ((word *)temp_sample.data)[j] = temp;
13621 89161498 }
13622 }
13623 3072 }
13624
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21165 times.
25743 else if(i < Z35)
13625 {
13626 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13627 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13628 4578 set_bit(tempflag, i-1, 1);
13629 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13630 4578 temp_sample.data = calloc(len,1);
13631 4578 memcpy(temp_sample.data, datsamp->data, len);
13632 4578 }
13633 21165 else continue;
13634
13635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7650 times.
7650 if(customsfxdata[i].data!=NULL)
13636 {
13637 // delete [] customsfxdata[i].data;
13638 7650 free(customsfxdata[i].data);
13639 7650 }
13640
13641 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13642 7650 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13643 7650 customsfxdata[i].data = calloc(len2,1);
13644 7650 customsfxdata[i].bits = temp_sample.bits;
13645 7650 customsfxdata[i].stereo = temp_sample.stereo;
13646 7650 customsfxdata[i].freq = temp_sample.freq;
13647 7650 customsfxdata[i].priority = temp_sample.priority;
13648 7650 customsfxdata[i].len = temp_sample.len;
13649 7650 customsfxdata[i].loop_start = temp_sample.loop_start;
13650 7650 customsfxdata[i].loop_end = temp_sample.loop_end;
13651 7650 customsfxdata[i].param = temp_sample.param;
13652 7650 int32_t cpylen = len2;
13653
13654
1/2
✓ Branch 0 taken 7650 times.
✗ Branch 1 not taken.
7650 if(s_version<3)
13655 {
13656 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13657 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13658 }
13659
13660 7650 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13661
13662 7650 free(temp_sample.data);
13663 7650 }
13664
13665 113 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13666
13667 113 sfxdat=0;
13668 113 return 0;
13669 113 }
13670
13671 129 void setupsfx()
13672 {
13673
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=1; i<WAV_COUNT; i++)
13674 {
13675 32895 sprintf(sfx_string[i],"s%03d",i);
13676
13677
2/2
✓ Branch 0 taken 25155 times.
✓ Branch 1 taken 7740 times.
32895 if(i<Z35)
13678 {
13679 7740 strcpy(sfx_string[i], old_sfx_string[i-1]);
13680 7740 }
13681
13682 32895 memset(customsfxflag, 0, WAV_COUNT>>3);
13683
13684 32895 int32_t j=i;
13685
13686
2/2
✓ Branch 0 taken 7869 times.
✓ Branch 1 taken 25026 times.
32895 if(i>Z35)
13687 {
13688 25026 i=Z35;
13689 25026 }
13690
13691 32895 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13692
13693
2/2
✓ Branch 0 taken 29580 times.
✓ Branch 1 taken 3315 times.
32895 if(customsfxdata[j].data!=NULL)
13694 {
13695 // delete [] customsfxdata[j].data;
13696 3315 free(customsfxdata[j].data);
13697 3315 }
13698
13699 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13700 32895 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13701 32895 customsfxdata[j].bits = temp_sample->bits;
13702 32895 customsfxdata[j].stereo = temp_sample->stereo;
13703 32895 customsfxdata[j].freq = temp_sample->freq;
13704 32895 customsfxdata[j].priority = temp_sample->priority;
13705 32895 customsfxdata[j].len = temp_sample->len;
13706 32895 customsfxdata[j].loop_start = temp_sample->loop_start;
13707 32895 customsfxdata[j].loop_end = temp_sample->loop_end;
13708 32895 customsfxdata[j].param = temp_sample->param;
13709 32895 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13710 32895 i=j;
13711 32895 }
13712 129 }
13713
13714 extern char *guy_string[eMAXGUYS];
13715 extern const char *old_guy_string[OLDMAXGUYS];
13716
13717 129 int32_t readguys(PACKFILE *f, zquestheader *Header)
13718 {
13719 dword dummy;
13720 word guy_cversion;
13721 129 word guyversion=0;
13722
13723
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version >= 0x193)
13724 {
13725 //section version info
13726
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guyversion,f))
13727 {
13728 return qe_invalid;
13729 }
13730
13731 125 FFCore.quest_format[vGuys] = guyversion;
13732
13733 //al_trace("Guys version %d\n", guyversion);
13734
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guy_cversion,f))
13735 {
13736 return qe_invalid;
13737 }
13738 125 al_trace("Guy CVersion is: %d\n", guy_cversion);
13739 //section size
13740
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
13741 {
13742 return qe_invalid;
13743 }
13744 125 }
13745
13746
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(guyversion > 3)
13747 {
13748
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13749 {
13750 char tempname[64];
13751
13752 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13753 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13755 {
13756 memset(tempname, 0, sizeof(char)*64);
13757 sprintf(tempname, "e%03d", i);
13758 strcpy(guy_string[i], tempname);
13759
13760 continue;
13761 }
13762
13763
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(tempname, 64, f))
13764 {
13765 return qe_invalid;
13766 }
13767
13768 // Don't retain names of uneditable enemy entries!
13769 // for version upgrade to 2.5
13770
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= 177)
13771 {
13772 // some of the older builds have names such as 'zz123',
13773 // (this order gets messed up with some eXXX and some zzXXX)
13774 // so let's update to the newer naming convection. -Gleeok
13775 char tmpbuf[64];
13776 memset(tmpbuf, 0, sizeof(char)*64);
13777 sprintf(tmpbuf, "zz%03d", i);
13778
13779 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13780 {
13781 memset(tempname, 0, sizeof(char)*64);
13782 sprintf(tempname, "e%03d", i);
13783 }
13784 }
13785
13786
6/6
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 37855 times.
✓ Branch 2 taken 18984 times.
✓ Branch 3 taken 1017 times.
✓ Branch 4 taken 15955 times.
✓ Branch 5 taken 3029 times.
57856 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13787 {
13788 54827 guy_string[i][0] = '\0';
13789 54827 strncat(guy_string[i], tempname, 64 - 1);
13790 54827 }
13791 else
13792 {
13793 3029 strcpy(guy_string[i],old_guy_string[i]);
13794 }
13795 57856 }
13796 113 }
13797 else
13798 {
13799
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13800 {
13801 8192 sprintf(guy_string[i],"zz%03d",i);
13802 8192 }
13803
13804
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13805 {
13806 2832 strcpy(guy_string[i],old_guy_string[i]);
13807 2832 }
13808 }
13809
13810
13811 //finally... section data
13812 129 init_guys(guyversion); //using default data for now...
13813
13814 // Goriya guy fix
13815
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13816 {
13817
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13818 {
13819 12 guysbuf[gGORIYA].tile=130;
13820 12 guysbuf[gGORIYA].e_tile=130;
13821 12 }
13822 16 }
13823
13824
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193)
13825 {
13826
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13827 {
13828 guysbuf[eDODONGO].cset=14;
13829 guysbuf[eDODONGO].bosspal=spDIG;
13830 }
13831 4 }
13832 // Not sure when this first changed, but it's necessary for 2.10, at least
13833 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13834 //2.10 Fixes
13835
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13836 {
13837 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13838 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13839 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13840 16 guysbuf[eCENT1].misc3 = 1;
13841 16 guysbuf[eCENT2].misc3 = 1;
13842 16 }
13843
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13844 {
13845 129 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13846 129 }
13847
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version <= 0x210)
13848 {
13849 16 guysbuf[eGLEEOK1F].misc6 = 16;
13850 16 guysbuf[eGLEEOK2F].misc6 = 16;
13851 16 guysbuf[eGLEEOK3F].misc6 = 16;
13852 16 guysbuf[eGLEEOK4F].misc6 = 16;
13853
13854 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13855 16 guysbuf[eBATROBE].misc4 = 1;
13856 //guysbuf[eSUMMONER].misc4 = 1;
13857 16 guysbuf[eWWIZ].misc4 = 1;
13858 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13859 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13860 16 }
13861
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version == 0x190)
13862 {
13863 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13864 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13865 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13866 4 }
13867
13868 // The versions here may not be correct
13869 // zelda_version>=0x211 handled at guyversion<24
13870
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version <= 0x190)
13871 {
13872 4 guysbuf[eCENT1].misc3 = 0;
13873 4 guysbuf[eCENT2].misc3 = 0;
13874 4 guysbuf[eMOLDORM].misc2 = 0;
13875 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13876 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13877 4 }
13878
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 else if(Header->zelda_version <= 0x210)
13879 {
13880 12 guysbuf[eCENT1].misc3 = 1;
13881 12 guysbuf[eCENT2].misc3 = 1;
13882 12 guysbuf[eMOLDORM].misc2 = 0;
13883 12 }
13884
13885
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13886 {
13887 16 guysbuf[eKEESE1].misc16 = 120;
13888 16 guysbuf[eKEESE2].misc16 = 120;
13889 16 guysbuf[eKEESE3].misc16 = 120;
13890 16 guysbuf[eKEESETRIB].misc16 = 120;
13891 16 guysbuf[eKEESE1].misc17 = 16;
13892 16 guysbuf[eKEESE2].misc17 = 16;
13893 16 guysbuf[eKEESE3].misc17 = 16;
13894 16 guysbuf[eKEESETRIB].misc17 = 16;
13895
13896 16 guysbuf[ePEAHAT].misc16 = 80;
13897 16 guysbuf[ePEAHAT].misc17 = 16;
13898
13899 16 guysbuf[eGHINI2].misc16 = 120;
13900 16 guysbuf[eGHINI2].misc17 = 10;
13901
13902 16 }
13903
13904
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(guyversion<=2)
13905 {
13906 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13907 }
13908
13909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(guyversion > 3)
13910 {
13911 guydata tempguy;
13912
13913
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13914 {
13915
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 23) // May 2012 : 512 max enemies
13916 {
13917 if(i >= OLDBETAMAXGUYS)
13918 {
13919 memset(&guysbuf[i], 0, sizeof(guydata));
13920 continue;
13921 }
13922 }
13923
13924 57856 memset(&tempguy, 0, sizeof(guydata));
13925
13926
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags),f))
13927 {
13928 return qe_invalid;
13929 }
13930
13931
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags2),f))
13932 {
13933 return qe_invalid;
13934 }
13935
13936
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13937 {
13938
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tile),f))
13939 {
13940 return qe_invalid;
13941 }
13942 18432 }
13943 else
13944 {
13945
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13946 {
13947 return qe_invalid;
13948 }
13949 }
13950
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.width),f))
13951 {
13952 return qe_invalid;
13953 }
13954
13955
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.height),f))
13956 {
13957 return qe_invalid;
13958 }
13959
13960
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13961 {
13962
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.s_tile),f))
13963 {
13964 return qe_invalid;
13965 }
13966 18432 }
13967 else
13968 {
13969
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13970 {
13971 return qe_invalid;
13972 }
13973 }
13974
13975
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_width),f))
13976 {
13977 return qe_invalid;
13978 }
13979
13980
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_height),f))
13981 {
13982 return qe_invalid;
13983 }
13984
13985
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13986 {
13987
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.e_tile),f))
13988 {
13989 return qe_invalid;
13990 }
13991 18432 }
13992 else
13993 {
13994
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13995 {
13996 return qe_invalid;
13997 }
13998 }
13999
14000
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_width),f))
14001 {
14002 return qe_invalid;
14003 }
14004
14005
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_height),f))
14006 {
14007 return qe_invalid;
14008 }
14009
14010
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hp),f))
14011 {
14012 return qe_invalid;
14013 }
14014
14015
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.family),f))
14016 {
14017 return qe_invalid;
14018 }
14019
14020
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57856 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14021 {
14022 if(get_qr(qr_NEWENEMYTILES))
14023 {
14024 tempguy.s_tile=tempguy.e_tile+120;
14025 tempguy.s_width=tempguy.e_width;
14026 tempguy.s_height=tempguy.e_height;
14027 }
14028 else tempguy.s_tile=860;
14029 }
14030
14031
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.cset),f))
14032 {
14033 return qe_invalid;
14034 }
14035
14036
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.anim),f))
14037 {
14038 return qe_invalid;
14039 }
14040
14041
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_anim),f))
14042 {
14043 return qe_invalid;
14044 }
14045
14046
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.frate),f))
14047 {
14048 return qe_invalid;
14049 }
14050
14051
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_frate),f))
14052 {
14053 return qe_invalid;
14054 }
14055
14056
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 13) // April 2009
14057 {
14058 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14059 {
14060 tempguy.frate *= 2;
14061 tempguy.e_frate *= 2;
14062 }
14063 }
14064
14065
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 14) // May 1 2009
14066 {
14067 if(tempguy.anim==a2FRMSLOW)
14068 {
14069 tempguy.anim=a2FRM;
14070 tempguy.frate *= 2;
14071 }
14072
14073 if(tempguy.e_anim==a2FRMSLOW)
14074 {
14075 tempguy.e_anim=a2FRM;
14076 tempguy.e_frate *= 2;
14077 }
14078
14079 if(tempguy.anim==aFLIPSLOW)
14080 {
14081 tempguy.anim=aFLIP;
14082 tempguy.frate *= 2;
14083 }
14084
14085 if(tempguy.e_anim==aFLIPSLOW)
14086 {
14087 tempguy.e_anim=aFLIP;
14088 tempguy.e_frate *= 2;
14089 }
14090
14091 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14092
14093 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14094
14095 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14096 {
14097 tempguy.anim=a4FRM4DIR;
14098 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14099 }
14100
14101 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14102 {
14103 tempguy.e_anim=a4FRM4DIR;
14104 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14105 }
14106 }
14107
14108
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.dp),f))
14109 {
14110 return qe_invalid;
14111 }
14112
14113 //correction for guy fire
14114
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 6)
14115 {
14116 if(i == gFIRE)
14117 tempguy.dp = 2;
14118 }
14119
14120
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.wdp),f))
14121 {
14122 return qe_invalid;
14123 }
14124
14125
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.weapon),f))
14126 {
14127 return qe_invalid;
14128 }
14129
14130 //correction for bosses using triple, "rising" fireballs
14131
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 5)
14132 {
14133 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14134 i == eGOHMA3 || i == eGOHMA4)
14135 {
14136 if(tempguy.weapon == ewFireball)
14137 tempguy.weapon = ewFireball2;
14138 }
14139 }
14140
14141
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.rate),f))
14142 {
14143 return qe_invalid;
14144 }
14145
14146
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hrate),f))
14147 {
14148 return qe_invalid;
14149 }
14150
14151
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.step),f))
14152 {
14153 return qe_invalid;
14154 }
14155
14156 // HIGHLY UNORTHODOX UPDATING THING, part 2
14157
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 56320 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
57856 if(fixpolsvoice && tempguy.family==eePOLSV)
14158 {
14159 tempguy.step /= 2;
14160 }
14161
14162
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.homing),f))
14163 {
14164 return qe_invalid;
14165 }
14166
14167
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.grumble),f))
14168 {
14169 return qe_invalid;
14170 }
14171
14172
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.item_set),f))
14173 {
14174 return qe_invalid;
14175 }
14176
14177
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14178 {
14179
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc1),f))
14180 {
14181 return qe_invalid;
14182 }
14183
14184
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc2),f))
14185 {
14186 return qe_invalid;
14187 }
14188
14189
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc3),f))
14190 {
14191 return qe_invalid;
14192 }
14193
14194
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc4),f))
14195 {
14196 return qe_invalid;
14197 }
14198
14199
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc5),f))
14200 {
14201 return qe_invalid;
14202 }
14203
14204
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc6),f))
14205 {
14206 return qe_invalid;
14207 }
14208
14209
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc7),f))
14210 {
14211 return qe_invalid;
14212 }
14213
14214
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc8),f))
14215 {
14216 return qe_invalid;
14217 }
14218
14219
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc9),f))
14220 {
14221 return qe_invalid;
14222 }
14223
14224
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc10),f))
14225 {
14226 return qe_invalid;
14227 }
14228 57856 }
14229 else
14230 {
14231 int16_t tempMisc;
14232
14233 if(!p_igetw(&tempMisc,f))
14234 {
14235 return qe_invalid;
14236 }
14237
14238 tempguy.misc1=tempMisc;
14239
14240 if(!p_igetw(&tempMisc,f))
14241 {
14242 return qe_invalid;
14243 }
14244
14245 tempguy.misc2=tempMisc;
14246
14247 if(!p_igetw(&tempMisc,f))
14248 {
14249 return qe_invalid;
14250 }
14251
14252 tempguy.misc3=tempMisc;
14253
14254 if(!p_igetw(&tempMisc,f))
14255 {
14256 return qe_invalid;
14257 }
14258
14259 tempguy.misc4=tempMisc;
14260
14261 if(!p_igetw(&tempMisc,f))
14262 {
14263 return qe_invalid;
14264 }
14265
14266 tempguy.misc5=tempMisc;
14267
14268 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14269 {
14270 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14271 tempguy.misc5 = 74;
14272 }
14273
14274 if(!p_igetw(&tempMisc,f))
14275 {
14276 return qe_invalid;
14277 }
14278
14279 tempguy.misc6=tempMisc;
14280
14281 if(!p_igetw(&tempMisc,f))
14282 {
14283 return qe_invalid;
14284 }
14285
14286 tempguy.misc7=tempMisc;
14287
14288 if(!p_igetw(&tempMisc,f))
14289 {
14290 return qe_invalid;
14291 }
14292
14293 tempguy.misc8=tempMisc;
14294
14295 if(!p_igetw(&tempMisc,f))
14296 {
14297 return qe_invalid;
14298 }
14299
14300 tempguy.misc9=tempMisc;
14301
14302 if(!p_igetw(&tempMisc,f))
14303 {
14304 return qe_invalid;
14305 }
14306
14307 tempguy.misc10=tempMisc;
14308 }
14309
14310
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bgsfx),f))
14311 {
14312 return qe_invalid;
14313 }
14314
14315
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bosspal),f))
14316 {
14317 return qe_invalid;
14318 }
14319
14320
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.extend),f))
14321 {
14322 return qe_invalid;
14323 }
14324
14325 //! Enemy Defences
14326
14327 //If a 2.50 quest, use only the 2.5 defences.
14328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14329 {
14330
2/2
✓ Branch 0 taken 1099264 times.
✓ Branch 1 taken 57856 times.
1157120 for(int32_t j=0; j<edefLAST; j++)
14331 {
14332
1/2
✓ Branch 0 taken 1099264 times.
✗ Branch 1 not taken.
1099264 if(!p_getc(&(tempguy.defense[j]),f))
14333 {
14334 return qe_invalid;
14335 }
14336 1099264 }
14337 //then copy the generic script defence to all the new script defences
14338
14339 57856 }
14340
14341
14342
14343
14344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 18)
14345 {
14346
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.hitsfx),f))
14347 {
14348 return qe_invalid;
14349 }
14350
14351
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.deadsfx),f))
14352 {
14353 return qe_invalid;
14354 }
14355 57856 }
14356
14357
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion >= 22)
14358 {
14359
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc11),f))
14360 {
14361 return qe_invalid;
14362 }
14363
14364
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc12),f))
14365 {
14366 return qe_invalid;
14367 }
14368 57856 }
14369 else if(guyversion >= 19)
14370 {
14371 int16_t tempMisc;
14372
14373 if(!p_igetw(&tempMisc,f))
14374 {
14375 return qe_invalid;
14376 }
14377
14378 tempguy.misc11=tempMisc;
14379
14380 if(!p_igetw(&tempMisc,f))
14381 {
14382 return qe_invalid;
14383 }
14384
14385 tempguy.misc12=tempMisc;
14386 }
14387
14388 //If a 2.54 or later quest, use all of the defences.
14389
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 24) // Add new guyversion conditional statement
14390 {
14391
2/2
✓ Branch 0 taken 405504 times.
✓ Branch 1 taken 18432 times.
423936 for(int32_t j=edefLAST; j<edefLAST255; j++)
14392 {
14393
1/2
✓ Branch 0 taken 405504 times.
✗ Branch 1 not taken.
405504 if(!p_getc(&(tempguy.defense[j]),f))
14394 {
14395 return qe_invalid;
14396 }
14397 405504 }
14398 18432 }
14399
14400
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14401 {
14402
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14403 {
14404 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14405 394240 }
14406 39424 }
14407
14408 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14409
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 25)
14410 {
14411
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.txsz),f))
14412 {
14413 return qe_invalid;
14414 }
14415
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tysz),f))
14416 {
14417 return qe_invalid;
14418 }
14419
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxsz),f))
14420 {
14421 return qe_invalid;
14422 }
14423
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hysz),f))
14424 {
14425 return qe_invalid;
14426 }
14427
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hzsz),f))
14428 {
14429 return qe_invalid;
14430 }
14431 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14432
14433 */
14434 18432 }
14435 //More Enemy Editor vars for 2.60
14436
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 26)
14437 {
14438
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxofs),f))
14439 {
14440 return qe_invalid;
14441 }
14442
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hyofs),f))
14443 {
14444 return qe_invalid;
14445 }
14446
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.xofs),f))
14447 {
14448 return qe_invalid;
14449 }
14450
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.yofs),f))
14451 {
14452 return qe_invalid;
14453 }
14454
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.zofs),f))
14455 {
14456 return qe_invalid;
14457 }
14458 18432 }
14459
14460
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14461 {
14462 39424 tempguy.wpnsprite = 0;
14463 39424 }
14464
14465
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 27)
14466 {
14467
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.wpnsprite),f))
14468 {
14469 return qe_invalid;
14470 }
14471 18432 }
14472
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14473 {
14474 39424 tempguy.SIZEflags = 0;
14475 39424 }
14476
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 28)
14477 {
14478
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.SIZEflags),f))
14479 {
14480 return qe_invalid;
14481 }
14482
14483 18432 }
14484
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14485 {
14486 39424 tempguy.frozentile = 0;
14487 39424 tempguy.frozencset = 0;
14488 39424 tempguy.frozenclock = 0;
14489
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14490 39424 }
14491
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 30)
14492 {
14493
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozentile),f))
14494 {
14495 return qe_invalid;
14496 }
14497
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozencset),f))
14498 {
14499 return qe_invalid;
14500 }
14501
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozenclock),f))
14502 {
14503 return qe_invalid;
14504 }
14505
2/2
✓ Branch 0 taken 184320 times.
✓ Branch 1 taken 18432 times.
202752 for ( int32_t q = 0; q < 10; q++ ) {
14506
1/2
✓ Branch 0 taken 184320 times.
✗ Branch 1 not taken.
184320 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14507 {
14508 return qe_invalid;
14509 }
14510 184320 }
14511
14512 18432 }
14513
14514
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 34)
14515 {
14516
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.firesfx),f))
14517 {
14518 return qe_invalid;
14519 }
14520
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc16),f))
14521 {
14522 return qe_invalid;
14523 }
14524
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc17),f))
14525 {
14526 return qe_invalid;
14527 }
14528
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc18),f))
14529 {
14530 return qe_invalid;
14531 }
14532
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc19),f))
14533 {
14534 return qe_invalid;
14535 }
14536
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc20),f))
14537 {
14538 return qe_invalid;
14539 }
14540
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc21),f))
14541 {
14542 return qe_invalid;
14543 }
14544
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc22),f))
14545 {
14546 return qe_invalid;
14547 }
14548
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc23),f))
14549 {
14550 return qe_invalid;
14551 }
14552
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc24),f))
14553 {
14554 return qe_invalid;
14555 }
14556
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc25),f))
14557 {
14558 return qe_invalid;
14559 }
14560
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc26),f))
14561 {
14562 return qe_invalid;
14563 }
14564
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc27),f))
14565 {
14566 return qe_invalid;
14567 }
14568
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc28),f))
14569 {
14570 return qe_invalid;
14571 }
14572
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc29),f))
14573 {
14574 return qe_invalid;
14575 }
14576
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc30),f))
14577 {
14578 return qe_invalid;
14579 }
14580
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc31),f))
14581 {
14582 return qe_invalid;
14583 }
14584
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc32),f))
14585 {
14586 return qe_invalid;
14587 }
14588
14589
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14590
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.movement[q]),f))
14591 {
14592 return qe_invalid;
14593 }
14594 589824 }
14595
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14596
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14597 {
14598 return qe_invalid;
14599 }
14600 589824 }
14601
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.script),f))
14602 {
14603 return qe_invalid;
14604 }
14605 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14606
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14607 {
14608
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.initD[q]),f))
14609 {
14610 return qe_invalid;
14611 }
14612 147456 }
14613
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 18432 times.
55296 for ( int32_t q = 0; q < 2; q++ )
14614 {
14615
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(!p_igetl(&(tempguy.initA[q]),f))
14616 {
14617 return qe_invalid;
14618 }
14619 36864 }
14620
14621 18432 }
14622
14623
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 37)
14624 {
14625
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.editorflags),f))
14626 {
14627 return qe_invalid;
14628 }
14629 18432 }
14630
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14631
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 38)
14632 {
14633
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc13),f))
14634 {
14635 return qe_invalid;
14636 }
14637
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc14),f))
14638 {
14639 return qe_invalid;
14640 }
14641
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc15),f))
14642 {
14643 return qe_invalid;
14644 }
14645
14646 18432 }
14647
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 38 )
14648 {
14649 39424 tempguy.misc13 = 0;
14650 39424 tempguy.misc14 = 0;
14651 39424 tempguy.misc15 = 0;
14652 39424 }
14653
14654
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 39 )
14655 {
14656
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14657 {
14658
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14659 {
14660
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14661 {
14662 return qe_invalid;
14663 }
14664 9584640 }
14665
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14666 {
14667
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14668 {
14669 return qe_invalid;
14670 }
14671 9584640 }
14672 147456 }
14673
14674
14675 18432 }
14676
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 39 ) //apply old InitD strings to both
14677 {
14678
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14679 {
14680 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14681 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14682 315392 }
14683 39424 }
14684
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 40 )
14685 {
14686
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.weaponscript),f))
14687 {
14688 return qe_invalid;
14689 }
14690 18432 }
14691
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 40 )
14692 {
14693 39424 tempguy.weaponscript = 0;
14694 39424 }
14695 //eweapon script InitD
14696
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 41 )
14697 {
14698
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14699 {
14700
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14701 {
14702 return qe_invalid;
14703 }
14704 147456 }
14705
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if ( guy_cversion < 4 )
14706 {
14707 if ( tempguy.family == eeKEESE )
14708 {
14709
14710 if ( !tempguy.misc1 )
14711 {
14712 tempguy.misc16 = 120;
14713 tempguy.misc17 = 16;
14714
14715 }
14716 }
14717 if ( tempguy.family == eePEAHAT )
14718 {
14719 tempguy.misc16 = 80;
14720 tempguy.misc17 = 16;
14721 }
14722
14723 if ( tempguy.family == eeGHINI )
14724 {
14725 tempguy.misc16 = 120;
14726 tempguy.misc17 = 10;
14727 }
14728
14729 }
14730 18432 }
14731
14732
14733
14734 //default weapon sprites (quest version < 2.54)
14735 //port over old defaults -Z
14736
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 32)
14737 {
14738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14739 {
14740
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14741 {
14742 case wNone:
14743 32842 tempguy.wpnsprite = 0; break;
14744
14745 case wSword:
14746 case wBeam:
14747 case wBrang:
14748 case wBomb:
14749 case wSBomb:
14750 case wLitBomb:
14751 case wLitSBomb:
14752 case wArrow:
14753 case wFire:
14754 case wWhistle:
14755 case wBait:
14756 case wWand:
14757 case wMagic:
14758 case wCatching:
14759 case wWind:
14760 case wRefMagic:
14761 case wRefFireball:
14762 case wRefRock:
14763 case wHammer:
14764 case wHookshot:
14765 case wHSHandle:
14766 case wHSChain:
14767 case wSSparkle:
14768 case wFSparkle:
14769 case wSmack:
14770 case wPhantom:
14771 case wCByrna:
14772 case wRefBeam:
14773 case wStomp:
14774 case lwMax:
14775 case wScript1:
14776 case wScript2:
14777 case wScript3:
14778 case wScript4:
14779 case wScript5:
14780 case wScript6:
14781 case wScript7:
14782 case wScript8:
14783 case wScript9:
14784 case wScript10:
14785 case wIce:
14786 //Cannot use any of these weapons yet.
14787 tempguy.wpnsprite = -1;
14788 break;
14789
14790 case wEnemyWeapons:
14791 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14792
14793 302 case ewArrow: tempguy.wpnsprite = 19; break;
14794 314 case ewBrang: tempguy.wpnsprite = 4; break;
14795 931 case ewSword: tempguy.wpnsprite = 20; break;
14796 493 case ewRock: tempguy.wpnsprite = 18; break;
14797 912 case ewMagic: tempguy.wpnsprite = 21; break;
14798 80 case ewBomb: tempguy.wpnsprite = 78; break;
14799 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14800 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14801 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14802 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14803 759 case ewFlame: tempguy.wpnsprite = 35; break;
14804 106 case ewWind: tempguy.wpnsprite = 36; break;
14805 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14806 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14807 case ewIce: tempguy.wpnsprite = 83; break;
14808 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14809
14810
14811 default: break; //No assign.
14812 }
14813 39424 }
14814 39424 }
14815
14816 //default weapon fire sound (quest version < 2.54)
14817 //port over old defaults and zero new data. -Z
14818
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 34)
14819 {
14820
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14821 {
14822 1261568 tempguy.movement[q] = 0;
14823 1261568 tempguy.new_weapon[q] = 0;
14824
14825 1261568 }
14826
14827 //NPC Script attributes.
14828 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14829
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14830
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14831
14832 39424 tempguy.misc16 = 0;
14833 39424 tempguy.misc17 = 0;
14834 39424 tempguy.misc18 = 0;
14835 39424 tempguy.misc19 = 0;
14836 39424 tempguy.misc20 = 0;
14837 39424 tempguy.misc21 = 0;
14838 39424 tempguy.misc22 = 0;
14839 39424 tempguy.misc23 = 0;
14840 39424 tempguy.misc24 = 0;
14841 39424 tempguy.misc25 = 0;
14842 39424 tempguy.misc26 = 0;
14843 39424 tempguy.misc27 = 0;
14844 39424 tempguy.misc28 = 0;
14845 39424 tempguy.misc29 = 0;
14846 39424 tempguy.misc30 = 0;
14847 39424 tempguy.misc31 = 0;
14848 39424 tempguy.misc32 = 0;
14849
14850 //old default sounds
14851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14852 {
14853
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14854 {
14855 case wNone:
14856 32842 tempguy.firesfx = 0; break;
14857
14858 case wSword:
14859 case wBeam:
14860 case wBrang:
14861 case wBomb:
14862 case wSBomb:
14863 case wLitBomb:
14864 case wLitSBomb:
14865 case wArrow:
14866 case wFire:
14867 case wWhistle:
14868 case wBait:
14869 case wWand:
14870 case wMagic:
14871 case wCatching:
14872 case wWind:
14873 case wRefMagic:
14874 case wRefFireball:
14875 case wRefRock:
14876 case wHammer:
14877 case wHookshot:
14878 case wHSHandle:
14879 case wHSChain:
14880 case wSSparkle:
14881 case wFSparkle:
14882 case wSmack:
14883 case wPhantom:
14884 case wCByrna:
14885 case wRefBeam:
14886 case wStomp:
14887 case lwMax:
14888 case wScript1:
14889 case wScript2:
14890 case wScript3:
14891 case wScript4:
14892 case wScript5:
14893 case wScript6:
14894 case wScript7:
14895 case wScript8:
14896 case wScript9:
14897 case wScript10:
14898 case wIce:
14899 //Cannot use any of these weapons yet.
14900 tempguy.firesfx = -1;
14901 break;
14902
14903 case wEnemyWeapons:
14904 1303 case ewFireball: tempguy.firesfx = 40; break;
14905
14906 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14907 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14908 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14909 493 case ewRock: tempguy.firesfx = 51; break;
14910 912 case ewMagic: tempguy.firesfx = 32; break;
14911 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14912 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14913 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14914 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14915 363 case ewFireTrail: tempguy.firesfx = 13; break;
14916 759 case ewFlame: tempguy.firesfx = 13; break;
14917 106 case ewWind: tempguy.firesfx = 32; break;
14918 80 case ewFlame2: tempguy.firesfx = 13; break;
14919 case ewFlame2Trail: tempguy.firesfx = 13; break;
14920 case ewIce: tempguy.firesfx = 44; break;
14921 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14922
14923 //what about special attacks (e.g. summoning == 56)
14924 default: break; //No assign.
14925 }
14926 39424 }
14927 39424 }
14928
14929 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14930
4/6
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 18432 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18432 times.
57856 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14931 {
14932
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14933 39424 }
14934 //Keese and bat halt rates.
14935
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
57856 if ( guyversion < 42 && guy_cversion < 4 )
14936 {
14937
14938
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14939 {
14940
14941
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14942 {
14943 326 tempguy.misc16 = 120;
14944 326 tempguy.misc17 = 16;
14945
14946 326 }
14947 529 }
14948
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14949 {
14950 167 tempguy.misc16 = 80;
14951 167 tempguy.misc17 = 16;
14952 167 }
14953
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14954 {
14955 77 tempguy.misc16 = 120;
14956 77 tempguy.misc17 = 10;
14957 77 }
14958
14959
14960 39424 }
14961
14962
14963 //miscellaneous other corrections
14964 //fix the mirror wizzrobe -DD
14965
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 7)
14966 {
14967 if(i == eMWIZ)
14968 {
14969 tempguy.misc2 = 0;
14970 tempguy.misc4 = 1;
14971 }
14972 }
14973
14974
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 8)
14975 {
14976 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14977 {
14978 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14979 tempguy.misc5 = 4; //neck length in segments
14980 tempguy.misc6 = 8; //neck offset from first body tile
14981 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14982 tempguy.misc8 = 168; //head offset from first body tile
14983 tempguy.misc9 = 228; //flying head offset from first body tile
14984
14985 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14986 {
14987 tempguy.misc6 += 10; //neck offset from first body tile
14988 tempguy.misc8 -= 12; //head offset from first body tile
14989 }
14990 }
14991 }
14992
14993
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14994 {
14995 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14996 tempguy.bosspal = spDIG;
14997 }
14998
14999
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 11) // December 2007 - Spinning Tile fix
15000 {
15001 if(tempguy.family==eeSPINTILE)
15002 {
15003 tempguy.flags |= guy_superman;
15004 tempguy.item_set = 0; // Don't drop items
15005 tempguy.step = 300;
15006 }
15007 }
15008
15009
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15010 {
15011 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15012 {
15013 if(tempguy.family==eeROPE)
15014 {
15015 tempguy.flags2 &= ~guy_flashing;
15016 }
15017 }
15018
15019 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15020 {
15021 if(tempguy.family==eeBUBBLE)
15022 {
15023 tempguy.flags2 &= ~guy_flashing;
15024 }
15025 }
15026
15027 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15028 {
15029 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15030 {
15031 tempguy.flags2 |= guy_blinking;
15032 }
15033
15034 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15035 {
15036 tempguy.flags2 |= guy_transparent;
15037 }
15038 }
15039 }
15040
15041
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15042 {
15043 if(i==gFIRE)
15044 {
15045 tempguy.e_anim = aFLIP;
15046 tempguy.e_frate = 24;
15047 }
15048
15049 if(i==gFAIRY)
15050 {
15051 tempguy.e_anim = a2FRM;
15052 tempguy.e_frate = 16;
15053 }
15054 }
15055
15056
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15057 {
15058 if(i==0) Z_message("Updating guys to version 16...\n");
15059
15060 update_guy_1(&tempguy);
15061
15062 if(i==eMPOLSV)
15063 {
15064 tempguy.defense[edefARROW] = edCHINK;
15065 tempguy.defense[edefMAGIC] = ed1HKO;
15066 tempguy.defense[edefREFMAGIC] = ed1HKO;
15067 }
15068 }
15069
15070
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 17) // December 2009
15071 {
15072 if(tempguy.family==eePROJECTILE)
15073 {
15074 tempguy.misc1 = 0;
15075 }
15076 }
15077
15078
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 18) // January 2010
15079 {
15080 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15081 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15082
15083 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15084 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15085
15086 if(tempguy.family == eeAQUA)
15087 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15088 else if(tempguy.family == eeMANHAN)
15089 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15090 else if(tempguy.family==eePATRA)
15091 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15092 else if(tempguy.family==eeGHOMA)
15093 {
15094 for(int32_t j=0; j<edefLAST; j++)
15095 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15096
15097 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15098
15099 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15100
15101 tempguy.misc1--;
15102 }
15103 else if(tempguy.family == eeGLEEOK)
15104 {
15105 for(int32_t j=0; j<edefLAST; j++)
15106 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15107
15108 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15109 }
15110 else if(tempguy.family == eeARMOS)
15111 {
15112 tempguy.family=eeWALK;
15113 tempguy.hrate = 0;
15114 tempguy.misc10 = tempguy.misc1;
15115 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15116 tempguy.misc9 = e9tARMOS;
15117 }
15118 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15119 {
15120 tempguy.family=eeWALK;
15121 tempguy.hrate = 0;
15122 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15123 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15124 }
15125
15126 // Spawn animation flags
15127 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15128 tempguy.flags |= guy_fadeflicker;
15129 else
15130 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15131 }
15132
15133
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 20) // April 2010
15134 {
15135 if(tempguy.family == eeTRAP)
15136 {
15137 tempguy.misc2 = tempguy.misc10;
15138
15139 if(tempguy.misc10>=1)
15140 {
15141 tempguy.misc1++;
15142 }
15143
15144 tempguy.misc10 = 0;
15145 }
15146
15147 // Bomb Blast fix
15148 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15149 tempguy.weapon = ewLitBomb;
15150 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15151 tempguy.weapon = ewLitSBomb;
15152 }
15153
15154
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 21) // September 2011
15155 {
15156 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15157 {
15158 if(tempguy.family == eeKEESETRIB)
15159 {
15160 tempguy.family = eeKEESE;
15161 tempguy.misc2 = e2tKEESETRIB;
15162 tempguy.misc1 = 0;
15163 }
15164
15165 tempguy.rate = 2;
15166 tempguy.hrate = 8;
15167 tempguy.homing = 0;
15168 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15169 }
15170 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15171 {
15172 if(tempguy.family == eePEAHAT)
15173 {
15174 tempguy.rate = 4;
15175 tempguy.step = 62;
15176 }
15177 else
15178 tempguy.step = 25;
15179
15180 tempguy.hrate = 8;
15181 tempguy.homing = 0;
15182 }
15183 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15184 {
15185 if(tempguy.family == eeMANHAN)
15186 tempguy.step=50;
15187
15188 tempguy.hrate = 16;
15189 tempguy.homing = 0;
15190 }
15191 else if(tempguy.family == eeGLEEOK)
15192 {
15193 tempguy.rate = 2;
15194 tempguy.homing = 0;
15195 tempguy.hrate = 9;
15196 tempguy.step=89;
15197 }
15198 else if(tempguy.family == eeGHINI)
15199 {
15200 tempguy.rate = 4;
15201 tempguy.hrate = 12;
15202 tempguy.step=62;
15203 tempguy.homing = 0;
15204 }
15205
15206 // Bigdig random rate fix
15207 if(tempguy.family==eeDIG && tempguy.misc10==1)
15208 {
15209 tempguy.rate = 2;
15210 }
15211 }
15212
15213
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 24) // November 2012
15214 {
15215 if(tempguy.family==eeLANM)
15216 tempguy.misc3 = 1;
15217 else if(tempguy.family==eeMOLD)
15218 tempguy.misc2 = 0;
15219 }
15220
15221
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15222 {
15223
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
15224 {
15225 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15226 38764 }
15227
15228 39424 }
15229 // does not seem to solve the issue!
15230
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if ( Header->zelda_version <= 0x210 )
15231 {
15232 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15233 if ( tempguy.family == eeDONGO )
15234 {
15235 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15236 }
15237 }
15238
15239
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion >= 42)
15240 {
15241
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 1024 times.
18432 if(guyversion >= 47)
15242 {
15243
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(!p_igetl(&(tempguy.moveflags),f))
15244 {
15245 return qe_invalid;
15246 }
15247 17408 }
15248 else
15249 {
15250 byte fl;
15251
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
15252 {
15253 return qe_invalid;
15254 }
15255 1024 tempguy.moveflags = fl;
15256 }
15257 18432 }
15258 else
15259 {
15260
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
15261 {
15262 //No gravity; floats over pits
15263 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15264 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15265 //Special (bosses, etc)
15266 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15267 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15268 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15269 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
15270 30899 break;
15271 //No gravity, but falls in pits
15272 case eeLEV:
15273 518 tempguy.moveflags = FLAG_CAN_PITFALL;
15274 518 break;
15275 //Bosses that respect pits
15276 case eeDONGO:
15277 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
15278 278 break;
15279 case eeLANM:
15280 241 tempguy.moveflags = 0;
15281 241 break;
15282 //Gravity, floats over pits
15283 case eeWIZZ: case eeWALLM: case eeGHINI:
15284 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15285 1202 break;
15286 //Gravity and falls in pits
15287 case eeWALK:
15288
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15289 601 break;
15290 [[fallthrough]];
15291 case eeOTHER:
15292 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15293 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15294 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15295 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15296 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15297 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15298 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15299 5685 }
15300 }
15301
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 43)
15302 {
15303
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
15304 {
15305 //No gravity; floats over pits
15306 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15307 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15308 //Special (bosses, etc)
15309 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15310 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15311 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15312 case eeWIZZ: case eeWALLM: case eeGHINI:
15313 //Gravity, floats over pits
15314 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15315 32101 break;
15316 }
15317 39424 }
15318
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion < 44)
15319 {
15320
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15321 {
15322 370 tempguy.flags |= guy_fadeinstant;
15323 370 }
15324 39424 }
15325
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion > 44)
15326 {
15327
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_shadow),f))
15328 {
15329 return qe_invalid;
15330 }
15331
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_death),f))
15332 {
15333 return qe_invalid;
15334 }
15335
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_spawn),f))
15336 {
15337 return qe_invalid;
15338 }
15339 18432 }
15340 else
15341 {
15342
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15343 39424 tempguy.spr_death = iwDeath;
15344 39424 tempguy.spr_spawn = iwSpawn;
15345 }
15346
15347
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 46)
15348 {
15349
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15350 {
15351 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15352 321 }
15353 39424 }
15354
15355 57856 guysbuf[i] = tempguy;
15356 57856 }
15357 113 }
15358
15359 113 return 0;
15360 129 }
15361
15362 void update_guy_1(guydata *tempguy) // November 2009
15363 {
15364 bool doesntcount = false;
15365 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15366
15367 switch(tempguy->family)
15368 {
15369 case 1: //eeWALK
15370 switch(tempguy->misc10)
15371 {
15372 case 0: //Stalfos
15373 if(tempguy->misc1==1) // Fires four projectiles at once
15374 tempguy->misc1=4;
15375
15376 break;
15377
15378 case 1: //Darknut
15379 goto darknuts;
15380 break;
15381 }
15382
15383 tempguy->misc10 = 0;
15384 break;
15385
15386 case 2: //eeSHOOT
15387 tempguy->family = eeWALK;
15388
15389 switch(tempguy->misc10)
15390 {
15391 case 0: //Octorok
15392 if(tempguy->misc1==1||tempguy->misc1==2)
15393 {
15394 tempguy->misc1=e1tFIREOCTO;
15395 tempguy->misc2=e2tFIREOCTO;
15396 }
15397 else tempguy->misc1 = 0;
15398
15399 tempguy->misc6=tempguy->misc4;
15400 tempguy->misc4=tempguy->misc3;
15401 tempguy->misc3=0;
15402 break;
15403
15404 case 1: // Moblin
15405 tempguy->misc1 = 0;
15406 break;
15407
15408 case 2: //Lynel
15409 tempguy->misc6=tempguy->misc1+1;
15410 tempguy->misc1=0;
15411 break;
15412
15413 case 3: //Stalfos 2
15414 if(tempguy->misc1==1) // Fires four projectiles at once
15415 tempguy->misc1=e1t4SHOTS;
15416 else tempguy->misc1 = 0;
15417
15418 break;
15419
15420 case 4: //Darknut 5
15421 darknuts:
15422 tempguy->defense[edefFIRE] = edIGNORE;
15423 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15424 tempguy->defense[edefHOOKSHOT] = 0;
15425 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15426 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15427
15428 if(tempguy->misc1==1)
15429 tempguy->misc1=2;
15430 else if(tempguy->misc1==2)
15431 {
15432 tempguy->misc4=tempguy->misc3;
15433 tempguy->misc3=tempguy->misc2;
15434 tempguy->misc2=e2tSPLIT;
15435 tempguy->misc1 = 0;
15436 }
15437 else tempguy->misc1 = 0;
15438
15439 tempguy->flags |= inv_front;
15440
15441 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15442 tempguy->flags |= guy_bkshield;
15443
15444 break;
15445 }
15446
15447 tempguy->misc10 = 0;
15448 break;
15449
15450 /*
15451 case 9: //eeARMOS
15452 tempguy->family = eeWALK;
15453 break;
15454 */
15455 case 11: //eeGEL
15456 case 33: //eeGELTRIB
15457 if(tempguy->family==33)
15458 {
15459 tempguy->misc4 = 1;
15460
15461 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15462 tempguy->misc3 = tempguy->misc2;
15463
15464 tempguy->misc2 = e2tTRIBBLE;
15465 }
15466 else
15467 {
15468 tempguy->misc4 = 0;
15469 tempguy->misc3 = 0;
15470 tempguy->misc2 = 0;
15471 }
15472
15473 tempguy->family = eeWALK;
15474
15475 if(tempguy->misc1)
15476 {
15477 tempguy->misc1=1;
15478 tempguy->weapon = ewFireTrail;
15479 }
15480
15481 break;
15482
15483 case 34: //eeZOLTRIB
15484 case 12: //eeZOL
15485 tempguy->misc4=tempguy->misc3;
15486 tempguy->misc3=tempguy->misc2;
15487 tempguy->family = eeWALK;
15488 tempguy->misc2=e2tSPLITHIT;
15489
15490 if(tempguy->misc1)
15491 {
15492 tempguy->misc1=1;
15493 tempguy->weapon = ewFireTrail;
15494 }
15495
15496 break;
15497
15498 case 13: //eeROPE
15499 tempguy->family = eeWALK;
15500 tempguy->misc9 = e9tROPE;
15501
15502 if(tempguy->misc1)
15503 {
15504 tempguy->misc4 = tempguy->misc3;
15505 tempguy->misc3 = tempguy->misc2;
15506 tempguy->misc2 = e2tBOMBCHU;
15507 }
15508
15509 tempguy->misc1 = 0;
15510 break;
15511
15512 case 14: //eeGORIYA
15513 tempguy->family = eeWALK;
15514
15515 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15516
15517 break;
15518
15519 case 17: //eeBUBBLE
15520 tempguy->family = eeWALK;
15521 tempguy->misc8 = tempguy->misc2;
15522 tempguy->misc7 = tempguy->misc1 + 1;
15523 tempguy->misc1 = tempguy->misc2 = 0;
15524
15525 //fallthrogh
15526 case eeTRAP:
15527 case eeROCK:
15528 doesntcount = true;
15529 break;
15530
15531 case 35: //eeVIRETRIB
15532 case 18: //eeVIRE
15533 tempguy->family = eeWALK;
15534 tempguy->misc4=tempguy->misc3;
15535 tempguy->misc3=tempguy->misc2;
15536 tempguy->misc2=e2tSPLITHIT;
15537 tempguy->misc9=e9tVIRE;
15538 break;
15539
15540 case 19: //eeLIKE
15541 tempguy->family = eeWALK;
15542 tempguy->misc7 = e7tEATITEMS;
15543 tempguy->misc8=95;
15544 break;
15545
15546 case 20: //eePOLSV
15547 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15548 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15549 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15550 tempguy->defense[edefARROW] = ed1HKO;
15551 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15552 tempguy->family = eeWALK;
15553 tempguy->misc9 = e9tPOLSVOICE;
15554 tempguy->rate = 4;
15555 tempguy->homing = 32;
15556 tempguy->hrate = 10;
15557 tempguy->grumble = 0;
15558 break;
15559
15560 case eeWIZZ:
15561 if(tempguy->misc4)
15562 {
15563 for(int32_t i=0; i < edefLAST; i++)
15564 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15565 }
15566 else
15567 {
15568 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15569 tempguy->defense[edefMAGIC] = edCHINK;
15570 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15571 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15572 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15573 }
15574
15575 break;
15576
15577 case eePEAHAT:
15578 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15579
15580 if(!(tempguy->flags & guy_bhit))
15581 tempguy->defense[edefBRANG] = edSTUNONLY;
15582
15583 break;
15584
15585 case eeLEV:
15586 tempguy->defense[edefSTOMP] = edCHINK;
15587 break;
15588 }
15589
15590 // Old flags
15591 if(tempguy->flags & guy_superman)
15592 {
15593 for(int32_t i = 0; i < edefLAST; i++)
15594 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15595 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15596 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15597 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15598 }
15599
15600 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15601
15602 if(doesntcount)
15603 tempguy->flags |= (guy_doesntcount);
15604 }
15605
15606
15607 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15608 {
15609 byte tempbyte, padding;
15610 int32_t extras, secretcombos;
15611 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15613 {
15614 return qe_invalid;
15615 }
15616
15617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15618 return qe_invalid;
15619 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15620
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15621
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15622
15623
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15624 {
15625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15626 {
15627 return qe_invalid;
15628 }
15629
15630 6864 temp_mapscr->str=tempbyte;
15631 6864 }
15632 else
15633 {
15634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15635 {
15636 return qe_invalid;
15637 }
15638 }
15639
15640
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15641 {
15642 return qe_invalid;
15643 }
15644
15645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15646 {
15647 return qe_invalid;
15648 }
15649
15650
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15651 {
15652 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15653 93768 }
15654 else
15655 {
15656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15657 return qe_invalid;
15658 }
15659
15660
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15662 {
15663
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15664 {
15665 return qe_invalid;
15666 }
15667 6864 }
15668
15669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15670 {
15671 return qe_invalid;
15672 }
15673
15674
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15675 {
15676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15677 {
15678 return qe_invalid;
15679 }
15680 6864 }
15681
15682
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15683 {
15684
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15685 {
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15687 {
15688 return qe_invalid;
15689 }
15690 460224 }
15691 153408 }
15692 else
15693 {
15694 93768 temp_mapscr->tilewarptype[1]=0;
15695 93768 temp_mapscr->tilewarptype[2]=0;
15696 93768 temp_mapscr->tilewarptype[3]=0;
15697 }
15698
15699
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15700 {
15701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15702 {
15703 return qe_invalid;
15704 }
15705 240312 }
15706
15707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15708 {
15709 return qe_invalid;
15710 }
15711
15712 247176 temp_mapscr->warpreturnx[1]=0;
15713 247176 temp_mapscr->warpreturnx[2]=0;
15714 247176 temp_mapscr->warpreturnx[3]=0;
15715
15716
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15717 {
15718
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15719 {
15720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15721 {
15722 return qe_invalid;
15723 }
15724 460224 }
15725 153408 }
15726
15727
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15728 {
15729 return qe_invalid;
15730 }
15731
15732 247176 temp_mapscr->warpreturny[1]=0;
15733 247176 temp_mapscr->warpreturny[2]=0;
15734 247176 temp_mapscr->warpreturny[3]=0;
15735
15736
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15737 {
15738
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15739 {
15740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15741 {
15742 return qe_invalid;
15743 }
15744 460224 }
15745
15746
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15747 {
15748
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15749 {
15750 return qe_invalid;
15751 }
15752 153408 }
15753 else
15754 {
15755 byte temp;
15756
15757 if(!p_getc(&temp,f))
15758 {
15759 return qe_invalid;
15760 }
15761
15762 temp_mapscr->warpreturnc=temp<<8|temp;
15763 }
15764 153408 }
15765
15766
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15767
15768 {
15769 return qe_invalid;
15770 }
15771
15772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15773 {
15774 return qe_invalid;
15775 }
15776
15777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15778 {
15779 return qe_invalid;
15780 }
15781
15782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15783 {
15784 return qe_invalid;
15785 }
15786
15787
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15788 {
15789
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15790 {
15791 return qe_invalid;
15792 }
15793 153408 }
15794 else
15795 {
15796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15797 {
15798 return qe_invalid;
15799 }
15800
15801 93768 temp_mapscr->color = (word) tempbyte;
15802 }
15803
15804
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15805 {
15806 return qe_invalid;
15807 }
15808
15809
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15810 {
15811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15812 {
15813 return qe_invalid;
15814
15815 }
15816 988704 }
15817
15818
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15819 {
15820
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15821 {
15822 return qe_invalid;
15823 }
15824
15825 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15826
15827
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15828 {
15829 for(int32_t i=1; i<4; i++)
15830 {
15831 if(!p_getc(&(tempbyte),f))
15832 {
15833 return qe_invalid;
15834 }
15835
15836 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15837 }
15838 }
15839 else
15840 {
15841 93768 temp_mapscr->tilewarpdmap[1]=0;
15842 93768 temp_mapscr->tilewarpdmap[2]=0;
15843 93768 temp_mapscr->tilewarpdmap[3]=0;
15844 }
15845 93768 }
15846 else
15847 {
15848
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15849 {
15850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15851 {
15852 return qe_invalid;
15853 }
15854 613632 }
15855 }
15856
15857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15858 {
15859 return qe_invalid;
15860 }
15861
15862
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15863 {
15864
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15865 {
15866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15867 {
15868 return qe_invalid;
15869 }
15870 460224 }
15871 153408 }
15872 else
15873 {
15874 93768 temp_mapscr->tilewarpscr[1]=0;
15875 93768 temp_mapscr->tilewarpscr[2]=0;
15876 93768 temp_mapscr->tilewarpscr[3]=0;
15877 }
15878
15879
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15880 {
15881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15882 {
15883 return qe_invalid;
15884 }
15885 153408 }
15886 else
15887 {
15888 93768 temp_mapscr->tilewarpoverlayflags=0;
15889 }
15890
15891
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15892 {
15893 return qe_invalid;
15894 }
15895
15896
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15897 {
15898
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15899 {
15900 return qe_invalid;
15901 }
15902
15903 6864 }
15904
15905
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15906 {
15907 if(!p_getc(&padding,f))
15908 {
15909 return qe_invalid;
15910 }
15911 }
15912
15913
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15914 {
15915 /*
15916 if (!temp_mapscr->enemy[k])
15917 {
15918 continue;
15919 }
15920 */
15921
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15922 {
15923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15924 {
15925 return qe_invalid;
15926 }
15927
15928 68640 temp_mapscr->enemy[k]=tempbyte;
15929 68640 }
15930 else
15931 {
15932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15933 {
15934 return qe_invalid;
15935 }
15936 }
15937
15938
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15939 {
15940 //using enumerations here is dangerous
15941 //very easy to break old quests -DD
15942
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15943 {
15944 788 temp_mapscr->enemy[k]+=5;
15945 788 }
15946
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15947 {
15948 40 temp_mapscr->enemy[k]+=1;
15949 40 }
15950 68640 }
15951
15952
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15953 {
15954
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15955 {
15956 81175 temp_mapscr->enemy[k]+=10;
15957 81175 }
15958 937680 }
15959 //don't read in any invalid data
15960
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15961 {
15962 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15963 90 temp_mapscr->enemy[k] = 0;
15964 90 }
15965 2471760 }
15966
15967
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15968 {
15969 return qe_invalid;
15970 }
15971
15972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15973 {
15974 return qe_invalid;
15975 }
15976
15977
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15978 {
15979
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15980 {
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15982 {
15983 return qe_invalid;
15984 }
15985 460224 }
15986 153408 }
15987 else
15988 {
15989 93768 temp_mapscr->sidewarptype[1]=0;
15990 93768 temp_mapscr->sidewarptype[2]=0;
15991 93768 temp_mapscr->sidewarptype[3]=0;
15992 }
15993
15994
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15995 {
15996
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15997 {
15998 return qe_invalid;
15999 }
16000 153408 }
16001 else
16002 {
16003 93768 temp_mapscr->sidewarpoverlayflags=0;
16004 }
16005
16006
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16007 {
16008 return qe_invalid;
16009 }
16010
16011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16012 {
16013 return qe_invalid;
16014 }
16015
16016
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
16017 {
16018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
16019 {
16020 return qe_invalid;
16021 }
16022 988704 }
16023
16024
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
16025 {
16026 return qe_invalid;
16027 }
16028
16029
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16030 {
16031
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
16032 {
16033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16034 {
16035 return qe_invalid;
16036 }
16037 460224 }
16038 153408 }
16039 else
16040 {
16041 93768 temp_mapscr->sidewarpscr[1]=0;
16042 93768 temp_mapscr->sidewarpscr[2]=0;
16043 93768 temp_mapscr->sidewarpscr[3]=0;
16044 }
16045
16046
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
16047 {
16048
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
16049 {
16050 return qe_invalid;
16051 }
16052
16053 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16054
16055
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16056 {
16057 for(int32_t i=1; i<4; i++)
16058 {
16059 if(!p_getc(&(tempbyte),f))
16060 {
16061 return qe_invalid;
16062 }
16063
16064 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16065 }
16066 }
16067 else
16068 {
16069 93768 temp_mapscr->sidewarpdmap[1]=0;
16070 93768 temp_mapscr->sidewarpdmap[2]=0;
16071 93768 temp_mapscr->sidewarpdmap[3]=0;
16072 }
16073 93768 }
16074 else
16075 {
16076
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
16077 {
16078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16079 {
16080 return qe_invalid;
16081 }
16082 613632 }
16083 }
16084
16085
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16086 {
16087
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16088 {
16089 return qe_invalid;
16090 }
16091 153408 }
16092 93768 else temp_mapscr->sidewarpindex = 0;
16093
16094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
16095 {
16096 return qe_invalid;
16097 }
16098
16099
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
16100 {
16101
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
16102 {
16103 return qe_invalid;
16104 }
16105 6864 }
16106
16107
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16108 {
16109 return qe_invalid;
16110 }
16111
16112
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
16113 {
16114 return qe_invalid;
16115 }
16116
16117
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
16118 {
16119 return qe_invalid;
16120 }
16121
16122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
16123 {
16124 return qe_invalid;
16125 }
16126
16127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
16128 {
16129 return qe_invalid;
16130 }
16131
16132
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16133 //if (version>2)
16134 {
16135
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
16136 {
16137 return qe_invalid;
16138 }
16139 153408 }
16140
16141
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16142 {
16143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
16144 {
16145 return qe_invalid;
16146 }
16147
16148
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
16149 {
16150 return qe_invalid;
16151 }
16152
16153
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
16154 {
16155 return qe_invalid;
16156 }
16157
16158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
16159 {
16160 temp_mapscr->flags5 &= ~32;
16161 temp_mapscr->noreset |= 48;
16162 }
16163
16164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
16165 {
16166 if(temp_mapscr->noreset&1)
16167 {
16168 temp_mapscr->noreset|=8192;
16169 }
16170
16171 if(temp_mapscr->nocarry&1)
16172 {
16173 temp_mapscr->nocarry|=8192;
16174 temp_mapscr->nocarry&=~1;
16175 }
16176 }
16177 153408 }
16178 else
16179 {
16180 93768 temp_mapscr->flags5 = 0;
16181 93768 temp_mapscr->noreset = 0;
16182 93768 temp_mapscr->nocarry = 0;
16183 }
16184
16185
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16186 {
16187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
16188 {
16189 return qe_invalid;
16190 }
16191 153408 }
16192
16193
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
16194 {
16195
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
16196 {
16197 return qe_invalid;
16198 }
16199
16200
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
16201 {
16202 return qe_invalid;
16203 }
16204
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
16206 {
16207 return qe_invalid;
16208 }
16209
16210
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
16211 {
16212 return qe_invalid;
16213 }
16214
16215
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
16216 {
16217 return qe_invalid;
16218 }
16219 153408 }
16220 else
16221 {
16222 93768 temp_mapscr->csensitive=1;
16223 }
16224
16225
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
16226 {
16227
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
16228 {
16229 100 temp_mapscr->bosssfx=
16230
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16231 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16232 WAV_ROAR;
16233 100 }
16234
16235
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
16236 {
16237 91 temp_mapscr->oceansfx=WAV_SEA;
16238 91 }
16239
16240 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16241 ? 0 : WAV_SECRET;
16242
16243 93768 temp_mapscr->flags3 &= ~66; //64|2
16244 93768 temp_mapscr->flags2 &= ~32;
16245 93768 temp_mapscr->flags &= ~136; // 128|8
16246 93768 }
16247 else
16248 {
16249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
16250 {
16251 return qe_invalid;
16252 }
16253
16254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
16255 {
16256 return qe_invalid;
16257 }
16258
16259
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
16260 {
16261 return qe_invalid;
16262 }
16263 }
16264
16265
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
16266 {
16267 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
16268 93768 }
16269 else
16270 {
16271
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16272 {
16273 return qe_invalid;
16274 }
16275 }
16276
16277
16278
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16279 {
16280
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16281 {
16282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16283 {
16284 return qe_invalid;
16285 }
16286 1441872 }
16287
16288
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
16289 {
16290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16291 {
16292 return qe_invalid;
16293 }
16294 1441872 }
16295 240312 }
16296
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16297 {
16298 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16299 {
16300 return qe_invalid;
16301 }
16302
16303 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16304 {
16305 return qe_invalid;
16306 }
16307
16308 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16309 {
16310 return qe_invalid;
16311 }
16312
16313 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16314
16315 {
16316 return qe_invalid;
16317 }
16318 }
16319
16320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16321 {
16322 for(int32_t k=0; k<6; k++)
16323 {
16324 if(!p_getc(&tempbyte,f)) //layerxsize
16325 {
16326 return qe_invalid;
16327 }
16328 }
16329
16330 for(int32_t k=0; k<6; k++)
16331 {
16332 if(!p_getc(&tempbyte,f)) //layerxspeed
16333 {
16334 return qe_invalid;
16335 }
16336 }
16337
16338 for(int32_t k=0; k<6; k++)
16339 {
16340 if(!p_getc(&tempbyte,f)) //layerxdelay
16341 {
16342 return qe_invalid;
16343 }
16344 }
16345
16346 for(int32_t k=0; k<6; k++)
16347 {
16348 if(!p_getc(&tempbyte,f)) //layerysize
16349 {
16350 return qe_invalid;
16351 }
16352 }
16353
16354 for(int32_t k=0; k<6; k++)
16355 {
16356 if(!p_getc(&tempbyte,f)) //layeryspeed
16357 {
16358 return qe_invalid;
16359 }
16360 }
16361
16362 for(int32_t k=0; k<6; k++)
16363 {
16364 if(!p_getc(&tempbyte,f)) //layerydelay
16365 {
16366 return qe_invalid;
16367 }
16368 }
16369 }
16370
16371
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16372 {
16373
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16374 {
16375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16376 {
16377 return qe_invalid;
16378 }
16379 1441872 }
16380 240312 }
16381
16382
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16383 {
16384
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16385 {
16386 if(!p_getc(&padding,f))
16387 {
16388 return qe_invalid;
16389 }
16390 }
16391
16392
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16393 {
16394 return qe_invalid;
16395 }
16396 240312 }
16397
16398
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16399 {
16400 6864 extras=15;
16401 6864 }
16402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16403 {
16404 extras=11;
16405 }
16406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16407 {
16408 extras=32;
16409 }
16410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16411 {
16412 extras=64;
16413 }
16414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16415 {
16416 extras=62;
16417 }
16418 else
16419
16420 {
16421 240312 extras=0;
16422 }
16423
16424
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16425 {
16426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16427 {
16428 return qe_invalid;
16429 }
16430 102960 }
16431
16432
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16433 //if (version>3)
16434 {
16435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16436 {
16437 return qe_invalid;
16438 }
16439
16440
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16441 {
16442 return qe_invalid;
16443 }
16444 153408 }
16445 else
16446 {
16447 93768 temp_mapscr->nextmap=0;
16448 93768 temp_mapscr->nextscr=0;
16449 }
16450
16451
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16452 {
16453 6864 secretcombos=20;
16454 6864 }
16455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16456 {
16457 secretcombos=256;
16458 }
16459 else
16460 {
16461 240312 secretcombos=128;
16462 }
16463
16464
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16465 {
16466
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16467 {
16468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16469 {
16470 return qe_invalid;
16471 }
16472
16473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16474 {
16475 137280 temp_mapscr->secretcombo[k]=tempbyte;
16476 137280 }
16477 137280 }
16478 6864 }
16479 else
16480 {
16481
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16482 {
16483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16484 {
16485 return qe_invalid;
16486 }
16487
16488 30759936 }
16489 }
16490
16491
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16492 {
16493
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16494 {
16495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16496 {
16497 return qe_invalid;
16498 }
16499 30759936 }
16500
16501
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16502 {
16503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16504 {
16505 return qe_invalid;
16506 }
16507 30759936 }
16508 240312 }
16509
16510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16511 {
16512 if(!p_getc(&padding,f))
16513 {
16514 return qe_invalid;
16515 }
16516 }
16517
16518 247176 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16519
16520
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16521 {
16522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16523 {
16524 return qe_invalid;
16525 }
16526 43502976 }
16527
16528
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16529 {
16530 if(!p_getc(&padding,f))
16531 {
16532 return qe_invalid;
16533 }
16534
16535 if(!p_getc(&padding,f))
16536 {
16537 return qe_invalid;
16538 }
16539 }
16540
16541
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16542 {
16543
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16544 {
16545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16546 {
16547 return qe_invalid;
16548 }
16549
16550
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16551 {
16552 if(!p_getc(&tempbyte,f))
16553 {
16554 return qe_invalid;
16555 }
16556
16557 if(!p_getc(&tempbyte,f))
16558 {
16559 return qe_invalid;
16560 }
16561
16562 if(!p_getc(&tempbyte,f))
16563 {
16564 return qe_invalid;
16565 }
16566 }
16567 42294912 }
16568 240312 }
16569
16570
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16571 {
16572
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16573 {
16574
16575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16576 {
16577 return qe_invalid;
16578 }
16579 42294912 }
16580 240312 }
16581
16582
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16583 {
16584 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16585 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16586 6864 }
16587
16588
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16589 {
16590 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16591 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16592 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16593 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16594 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16595 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16596 6864 }
16597
16598
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16599 {
16600
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16601 {
16602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16603 {
16604 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16605 {
16606 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16607 }
16608 }
16609 else
16610 {
16611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16612 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16613 {
16614 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16615 1208064 }
16616
16617 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16618 }
16619
16620 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16621 1208064 }
16622 6864 }
16623
16624 /*if(version>12)
16625 {
16626 if(!p_getc(&(temp_mapscr->scrWidth),f))
16627 {
16628 return qe_invalid;
16629 }
16630 if(!p_getc(&(temp_mapscr->scrHeight),f))
16631 {
16632 return qe_invalid;
16633 }
16634 }*/
16635
16636
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16637 {
16638
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16639 {
16640 return qe_invalid;
16641 }
16642 153408 }
16643 else
16644 {
16645 93768 temp_mapscr->screen_midi = -1;
16646 }
16647
16648
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16649 {
16650
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16651 {
16652 return qe_invalid;
16653 }
16654 153408 }
16655 else
16656 {
16657 93768 temp_mapscr->lens_layer = llNORMAL;
16658 }
16659
16660
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16661 {
16662 dword bits;
16663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16664 {
16665 return qe_invalid;
16666 }
16667
16668 int32_t m;
16669 float tempfloat;
16670 word tempw;
16671 153408 temp_mapscr->ffcCountMarkDirty();
16672
16673
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16674 {
16675 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16676 4909056 tempffc.clear();
16677
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16678 {
16679
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16680 {
16681 return qe_invalid;
16682 }
16683 22989 tempffc.setData(tempw);
16684
16685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16686 {
16687 return qe_invalid;
16688 }
16689
16690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16691 {
16692 return qe_invalid;
16693 }
16694
16695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16696 {
16697 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16698 {
16699 return qe_invalid;
16700 }
16701
16702 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16703
16704 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16705 {
16706 return qe_invalid;
16707 }
16708
16709 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16710
16711 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16712 {
16713 return qe_invalid;
16714 }
16715
16716 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16717
16718 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16719 {
16720 return qe_invalid;
16721 }
16722
16723 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16724
16725 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16726 {
16727 return qe_invalid;
16728 }
16729
16730 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16731
16732 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16733 {
16734 return qe_invalid;
16735 }
16736
16737 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16738 }
16739 else
16740 {
16741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16742 {
16743 return qe_invalid;
16744 }
16745
16746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16747 {
16748 return qe_invalid;
16749 }
16750
16751
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16752 {
16753 return qe_invalid;
16754 }
16755
16756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16757 {
16758 return qe_invalid;
16759 }
16760
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16762 {
16763 return qe_invalid;
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16767 {
16768 return qe_invalid;
16769 }
16770 }
16771
16772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16773 {
16774 return qe_invalid;
16775 }
16776
16777
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16778 {
16779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16780 {
16781 return qe_invalid;
16782 }
16783
16784 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16785 22989 tempffc.txsz = (tempbyte>>6)+1;
16786
16787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16788 {
16789 return qe_invalid;
16790 }
16791
16792 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16793 22989 tempffc.tysz = (tempbyte>>6)+1;
16794
16795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16796 {
16797 return qe_invalid;
16798 }
16799 22989 }
16800 else
16801 {
16802 tempffc.hit_width=16;
16803 tempffc.hit_height=16;
16804 tempffc.txsz=1;
16805 tempffc.tysz=1;
16806 tempffc.flags=0;
16807 }
16808
16809 22989 tempffc.updateSolid();
16810
16811
16812
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16813 {
16814 tempffc.flags|=ffIGNOREHOLDUP;
16815 }
16816
16817
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16818 {
16819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16820 {
16821 return qe_invalid;
16822 }
16823 22989 }
16824 else
16825 {
16826 tempffc.script=0;
16827 }
16828
16829
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16830 {
16831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16832 {
16833 return qe_invalid;
16834 }
16835
16836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16837 {
16838 return qe_invalid;
16839 }
16840
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16842 {
16843 return qe_invalid;
16844 }
16845
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16847 {
16848 return qe_invalid;
16849 }
16850
16851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16852 {
16853 return qe_invalid;
16854 }
16855
16856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16857 {
16858 return qe_invalid;
16859 }
16860
16861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16862 {
16863 return qe_invalid;
16864 }
16865
16866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16867 {
16868 return qe_invalid;
16869 }
16870
16871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16872 {
16873 return qe_invalid;
16874 }
16875
16876 22989 tempffc.inita[0]=tempbyte*10000;
16877
16878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16879 {
16880 return qe_invalid;
16881 }
16882
16883 22989 tempffc.inita[1]=tempbyte*10000;
16884 22989 }
16885 else
16886 {
16887 tempffc.inita[0] = 10000;
16888 tempffc.inita[1] = 10000;
16889 }
16890
16891
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16892 {
16893 fixffcs=true;
16894 }
16895 22989 }
16896 4909056 }
16897
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16898 {
16899 14727168 temp_mapscr->ffcs[m].clear();
16900 14727168 }
16901 153408 }
16902
16903 //add in the new whistle flags
16904
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16905 {
16906
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16907 {
16908 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16909 19 }
16910 93768 }
16911
16912 //2.55 starts here
16913
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16914 {
16915
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16916 {
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16918 {
16919 return qe_invalid;
16920 }
16921 137360 }
16922
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16923 {
16924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16925 {
16926 return qe_invalid;
16927 }
16928 137360 }
16929
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16930 {
16931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16932 {
16933 return qe_invalid;
16934 }
16935 137360 }
16936
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16937 {
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16939 {
16940 return qe_invalid;
16941 }
16942 137360 }
16943 13736 }
16944
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16945 {
16946 for ( int32_t q = 0; q < 10; q++ )
16947 {
16948 temp_mapscr->npcstrings[q] = 0;
16949 temp_mapscr->new_items[q] = 0;
16950 temp_mapscr->new_item_x[q] = 0;
16951 temp_mapscr->new_item_y[q] = 0;
16952 }
16953 }
16954
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16955 {
16956
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16957 {
16958 return qe_invalid;
16959 }
16960
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16961 {
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16963 {
16964 return qe_invalid;
16965 }
16966 109888 }
16967 13736 }
16968
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16969 {
16970 233440 temp_mapscr->script = 0;
16971
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16972 233440 }
16973
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16974 {
16975
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16976 {
16977 return qe_invalid;
16978 }
16979 13736 }
16980
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16981 {
16982 233440 temp_mapscr->preloadscript = 0;
16983 233440 }
16984 //all builds with version > 20 need this. -Z
16985
16986
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16987 {
16988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16989 {
16990 return qe_invalid;
16991 }
16992
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16993 {
16994 return qe_invalid;
16995 }
16996 13736 }
16997
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16998 {
16999 233440 temp_mapscr->hidelayers = 0;
17000 233440 temp_mapscr->hidescriptlayers = 0;
17001 233440 }
17002
17003 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17004 //May be any version before 2.11. -Z
17005 /* --not the roar, the HIT SFX
17006 if ( Header->zelda_version <= 0x210 )
17007 {
17008 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17009 {
17010 temp_mapscr->bosssfx = WAV_ROAR;
17011 }
17012 }
17013 */
17014
17015 247176 return 0;
17016 247176 }
17017 263632 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version, int scrind)
17018 {
17019
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 16456 times.
263632 if(version < 23)
17020 {
17021 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
17023 247176 }
17024 else
17025 {
17026
1/2
✓ Branch 0 taken 16456 times.
✗ Branch 1 not taken.
16456 if(!p_getc(&(temp_mapscr->valid),f))
17027 return qe_invalid;
17028
2/2
✓ Branch 0 taken 10383 times.
✓ Branch 1 taken 6073 times.
16456 if(!(temp_mapscr->valid & mVALID))
17029 {
17030 10383 int map = scrind/MAPSCRS;
17031 10383 int scr = scrind%MAPSCRS;
17032
4/6
✓ Branch 0 taken 4484 times.
✓ Branch 1 taken 5899 times.
✓ Branch 2 taken 4484 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4484 times.
✗ Branch 5 not taken.
10383 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
17033 {
17034 //Empty screen, apply autolayers
17035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4484 times.
4484 for(int q = 0; q < 6; ++q)
17036 {
17037 auto layermap = map_autolayers[map*6+q];
17038 temp_mapscr->layermap[q] = layermap;
17039 if(layermap)
17040 temp_mapscr->layerscreen[q] = scr;
17041 }
17042 4484 }
17043 10383 return 0;
17044 }
17045 uint32_t scr_has_flags;
17046
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetl(&scr_has_flags,f))
17047 return qe_invalid;
17048
17049
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 744 times.
6073 if(scr_has_flags & SCRHAS_ROOMDATA)
17050 {
17051
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_getc(&(temp_mapscr->guy),f))
17052 return qe_invalid;
17053
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 60 times.
744 if(version > 26)
17054 {
17055
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&(temp_mapscr->guytile),f))
17056 return qe_invalid;
17057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684 times.
684 if(!p_getc(&(temp_mapscr->guycs),f))
17058 return qe_invalid;
17059
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetw(&(temp_mapscr->roomflags),f))
17060 return qe_invalid;
17061 684 }
17062 else
17063 {
17064 60 temp_mapscr->guytile = -1; //signal to use default guy values
17065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17066
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17067 }
17068
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_igetw(&(temp_mapscr->str),f))
17069 return qe_invalid;
17070
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_getc(&(temp_mapscr->room),f))
17071 return qe_invalid;
17072
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_igetw(&(temp_mapscr->catchall),f))
17073 return qe_invalid;
17074 744 }
17075
2/2
✓ Branch 0 taken 5950 times.
✓ Branch 1 taken 123 times.
6073 if(scr_has_flags & SCRHAS_ITEM)
17076 {
17077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!p_getc(&(temp_mapscr->item),f))
17078 return qe_invalid;
17079
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_getc(&(temp_mapscr->hasitem),f))
17080 return qe_invalid;
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!p_getc(&(temp_mapscr->itemx),f))
17082 return qe_invalid;
17083
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_getc(&(temp_mapscr->itemy),f))
17084 return qe_invalid;
17085 123 }
17086
2/2
✓ Branch 0 taken 5716 times.
✓ Branch 1 taken 357 times.
6073 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17087 {
17088
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17089 return qe_invalid;
17090 357 }
17091
2/2
✓ Branch 0 taken 5829 times.
✓ Branch 1 taken 244 times.
6073 if(scr_has_flags & SCRHAS_TWARP)
17092 {
17093
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17094 {
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17096 return qe_invalid;
17097 976 }
17098
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17099 {
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17101 return qe_invalid;
17102 976 }
17103
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17104 {
17105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17106 return qe_invalid;
17107 976 }
17108
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17109 return qe_invalid;
17110 244 }
17111
2/2
✓ Branch 0 taken 5934 times.
✓ Branch 1 taken 139 times.
6073 if(scr_has_flags & SCRHAS_SWARP)
17112 {
17113
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17114 {
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17116 return qe_invalid;
17117 556 }
17118
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17119 {
17120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17121 return qe_invalid;
17122 556 }
17123
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17124 {
17125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17126 return qe_invalid;
17127 556 }
17128
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17129 return qe_invalid;
17130
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17131 return qe_invalid;
17132 139 }
17133
2/2
✓ Branch 0 taken 5636 times.
✓ Branch 1 taken 437 times.
6073 if(scr_has_flags & SCRHAS_WARPRET)
17134 {
17135
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 437 times.
2185 for(int32_t i=0; i<4; i++)
17136 {
17137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1748 times.
1748 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17138 return qe_invalid;
17139 1748 }
17140
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 437 times.
2185 for(int32_t i=0; i<4; i++)
17141 {
17142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1748 times.
1748 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17143 return qe_invalid;
17144 1748 }
17145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17146 return qe_invalid;
17147
1/2
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
437 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17148 return qe_invalid;
17149 437 }
17150
2/2
✓ Branch 0 taken 4945 times.
✓ Branch 1 taken 1128 times.
6073 if(scr_has_flags & SCRHAS_LAYERS)
17151 {
17152
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17153 {
17154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17155 return qe_invalid;
17156 6768 }
17157
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17158 {
17159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17160 return qe_invalid;
17161 6768 }
17162
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17163 {
17164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17165 return qe_invalid;
17166 6768 }
17167
1/2
✓ Branch 0 taken 1128 times.
✗ Branch 1 not taken.
1128 if(!p_getc(&(temp_mapscr->hidelayers),f))
17168 return qe_invalid;
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128 times.
1128 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17170 return qe_invalid;
17171 1128 }
17172
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_MAZE)
17173 {
17174 for(int32_t k=0; k<4; k++)
17175 {
17176 if(!p_getc(&(temp_mapscr->path[k]),f))
17177 return qe_invalid;
17178 }
17179 if(!p_getc(&(temp_mapscr->exitdir),f))
17180 return qe_invalid;
17181 }
17182
2/2
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 157 times.
6073 if(scr_has_flags & SCRHAS_D_S_U)
17183 {
17184
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17185 return qe_invalid;
17186
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 157 times.
785 for(int32_t k=0; k<4; k++)
17187 {
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 628 times.
628 if(!p_getc(&(temp_mapscr->door[k]),f))
17189 return qe_invalid;
17190 628 }
17191
17192
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_getc(&(temp_mapscr->stairx),f))
17193 return qe_invalid;
17194
17195
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_getc(&(temp_mapscr->stairy),f))
17196 return qe_invalid;
17197
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_igetw(&(temp_mapscr->undercombo),f))
17198 return qe_invalid;
17199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(!p_getc(&(temp_mapscr->undercset),f))
17200 return qe_invalid;
17201 157 }
17202
2/2
✓ Branch 0 taken 5637 times.
✓ Branch 1 taken 436 times.
6073 if(scr_has_flags & SCRHAS_FLAGS)
17203 {
17204
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags),f))
17205 return qe_invalid;
17206
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags2),f))
17207 return qe_invalid;
17208
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags3),f))
17209 return qe_invalid;
17210
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags4),f))
17211 return qe_invalid;
17212
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags5),f))
17213 return qe_invalid;
17214
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags6),f))
17215 return qe_invalid;
17216
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags7),f))
17217 return qe_invalid;
17218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_getc(&(temp_mapscr->flags8),f))
17219 return qe_invalid;
17220
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags9),f))
17221 return qe_invalid;
17222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_getc(&(temp_mapscr->flags10),f))
17223 return qe_invalid;
17224
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->enemyflags),f))
17225 return qe_invalid;
17226 436 }
17227
2/2
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 379 times.
6073 if(scr_has_flags & SCRHAS_ENEMY)
17228 {
17229
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 379 times.
4169 for(int32_t k=0; k<10; k++)
17230 {
17231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3790 times.
3790 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17232 return qe_invalid;
17233
1/2
✓ Branch 0 taken 3790 times.
✗ Branch 1 not taken.
3790 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17234 temp_mapscr->enemy[k] = 0;
17235 3790 }
17236
1/2
✓ Branch 0 taken 379 times.
✗ Branch 1 not taken.
379 if(!p_getc(&(temp_mapscr->pattern),f))
17237 return qe_invalid;
17238 379 }
17239
2/2
✓ Branch 0 taken 6040 times.
✓ Branch 1 taken 33 times.
6073 if(scr_has_flags & SCRHAS_CARRY)
17240 {
17241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
17242 return qe_invalid;
17243
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
17244 return qe_invalid;
17245
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
17246 return qe_invalid;
17247
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
17248 return qe_invalid;
17249 33 }
17250
2/2
✓ Branch 0 taken 6004 times.
✓ Branch 1 taken 69 times.
6073 if(scr_has_flags & SCRHAS_SCRIPT)
17251 {
17252
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetw(&(temp_mapscr->script),f))
17253 return qe_invalid;
17254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&(temp_mapscr->preloadscript),f))
17255 return qe_invalid;
17256
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 69 times.
621 for ( int32_t q = 0; q < 8; q++ )
17257 {
17258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552 times.
552 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17259 return qe_invalid;
17260 552 }
17261 69 }
17262
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_UNUSED)
17263 {
17264 for ( int32_t q = 0; q < 10; q++ )
17265 {
17266 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
17267 return qe_invalid;
17268 }
17269 for ( int32_t q = 0; q < 10; q++ )
17270 {
17271 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
17272 return qe_invalid;
17273 }
17274 for ( int32_t q = 0; q < 10; q++ )
17275 {
17276 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
17277 return qe_invalid;
17278 }
17279 for ( int32_t q = 0; q < 10; q++ )
17280 {
17281 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
17282 return qe_invalid;
17283 }
17284 }
17285
2/2
✓ Branch 0 taken 5652 times.
✓ Branch 1 taken 421 times.
6073 if(scr_has_flags & SCRHAS_SECRETS)
17286 {
17287
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17288 {
17289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17290 return qe_invalid;
17291 53888 }
17292
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17293 {
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17295 return qe_invalid;
17296 53888 }
17297
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17298 {
17299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17300 return qe_invalid;
17301 53888 }
17302 421 }
17303
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3128 times.
6073 if(scr_has_flags & SCRHAS_COMBOFLAG)
17304 {
17305
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17306 {
17307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_igetw(&(temp_mapscr->data[k]),f))
17308 return qe_invalid;
17309 550528 }
17310
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17311 {
17312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17313 return qe_invalid;
17314 550528 }
17315
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17316 {
17317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_getc(&(temp_mapscr->cset[k]),f))
17318 return qe_invalid;
17319 550528 }
17320 3128 }
17321
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_MISC)
17322 {
17323
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&(temp_mapscr->color),f))
17324 return qe_invalid;
17325
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->csensitive),f))
17326 return qe_invalid;
17327
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->oceansfx),f))
17328 return qe_invalid;
17329
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->bosssfx),f))
17330 return qe_invalid;
17331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(!p_getc(&(temp_mapscr->secretsfx),f))
17332 return qe_invalid;
17333
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17334 return qe_invalid;
17335
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17336 return qe_invalid;
17337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17338 return qe_invalid;
17339
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->lens_layer),f))
17340 return qe_invalid;
17341
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(version > 27)
17342 {
17343 if(!p_getc(&(temp_mapscr->lens_show),f))
17344 return qe_invalid;
17345 if(!p_getc(&(temp_mapscr->lens_hide),f))
17346 return qe_invalid;
17347 }
17348 6073 }
17349 else
17350 {
17351 temp_mapscr->screen_midi = -1;
17352 temp_mapscr->csensitive = 1;
17353 }
17354 //FFC
17355 6073 bool old_ff = version < 25;
17356 6073 dword bits = 0;
17357 6073 word numffc = 32;
17358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(old_ff)
17359 {
17360 if(!p_igetl(&bits,f))
17361 return qe_invalid;
17362 }
17363 else
17364 {
17365
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&numffc,f))
17366 return qe_invalid;
17367 }
17368 byte tempbyte;
17369 word tempw;
17370
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
6073 static ffcdata nil_ffc;
17371 6073 temp_mapscr->ffcCountMarkDirty();
17372
2/2
✓ Branch 0 taken 6073 times.
✓ Branch 1 taken 8316 times.
14389 for(word m = 0; m < numffc; ++m)
17373 {
17374
1/2
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
8316 ffcdata& tempffc = (m < MAXFFCS)
17375 8316 ? temp_mapscr->ffcs[m]
17376 : nil_ffc; //sanity
17377 8316 tempffc.clear();
17378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8316 if(old_ff && !(bits & (1<<m))) continue;
17379
17380
1/2
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
8316 if(!p_igetw(&tempw,f))
17381 return qe_invalid;
17382
3/4
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✓ Branch 3 taken 6770 times.
8316 if(!old_ff && !tempw) //empty ffc, nothing more to load
17383 6770 continue;
17384 1546 tempffc.setData(tempw);
17385
17386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.cset),f))
17387 return qe_invalid;
17388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetw(&(tempffc.delay),f))
17389 return qe_invalid;
17390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.x),f))
17391 return qe_invalid;
17392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.y),f))
17393 return qe_invalid;
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.vx),f))
17395 return qe_invalid;
17396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.vy),f))
17397 return qe_invalid;
17398
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetzf(&(tempffc.ax),f))
17399 return qe_invalid;
17400
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetzf(&(tempffc.ay),f))
17401 return qe_invalid;
17402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.link),f))
17403 return qe_invalid;
17404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(version < 24)
17405 {
17406 if(!p_getc(&tempbyte,f))
17407 return qe_invalid;
17408 tempffc.hit_width = (tempbyte&0x3F)+1;
17409 tempffc.txsz = (tempbyte>>6)+1;
17410 if(!p_getc(&tempbyte,f))
17411 return qe_invalid;
17412 tempffc.hit_height = (tempbyte&0x3F)+1;
17413 tempffc.tysz = (tempbyte>>6)+1;
17414 }
17415 else
17416 {
17417
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetl(&(tempffc.hit_width),f))
17418 return qe_invalid;
17419
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetl(&(tempffc.hit_height),f))
17420 return qe_invalid;
17421
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_getc(&(tempffc.txsz),f))
17422 return qe_invalid;
17423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.tysz),f))
17424 return qe_invalid;
17425 }
17426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetl(&(tempffc.flags),f))
17427 return qe_invalid;
17428 1546 tempffc.updateSolid();
17429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetw(&(tempffc.script),f))
17430 return qe_invalid;
17431
2/2
✓ Branch 0 taken 12368 times.
✓ Branch 1 taken 1546 times.
13914 for(auto q = 0; q < 8; ++q)
17432 {
17433
1/2
✓ Branch 0 taken 12368 times.
✗ Branch 1 not taken.
12368 if(!p_igetl(&(tempffc.initd[q]),f))
17434 return qe_invalid;
17435 12368 }
17436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempbyte),f))
17437 return qe_invalid;
17438 1546 tempffc.inita[0]=tempbyte*10000;
17439
17440
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_getc(&(tempbyte),f))
17441 return qe_invalid;
17442 1546 tempffc.inita[1]=tempbyte*10000;
17443 1546 }
17444
2/2
✓ Branch 0 taken 769028 times.
✓ Branch 1 taken 6073 times.
775101 for(word m = numffc; m < MAXFFCS; ++m)
17445 {
17446 769028 temp_mapscr->ffcs[m].clear();
17447 769028 }
17448 //END FFC
17449 }
17450 253249 return 0;
17451 263632 }
17452
17453
17454 129 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17455 {
17456 129 int32_t scr=0;
17457
17458 129 word version=0;
17459 dword dummy;
17460 int32_t screens_to_read;
17461
17462 129 mapscr temp_mapscr;
17463 zcmap temp_map;
17464 word temp_map_count;
17465 dword section_size;
17466
17467
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17468 {
17469 4 screens_to_read=MAPSCRS192b136;
17470 4 }
17471 else
17472 {
17473 125 screens_to_read=MAPSCRS;
17474 }
17475
17476
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
17477 {
17478 //section version info
17479
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
17480 {
17481 return qe_invalid;
17482 }
17483
17484 125 FFCore.quest_format[vMaps] = version;
17485
17486 //al_trace("Maps version %d\n", version);
17487
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
17488 {
17489 return qe_invalid;
17490 }
17491
17492 //section size
17493
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
17494 {
17495 return qe_invalid;
17496 }
17497
17498 //finally... section data
17499
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_map_count,f))
17500 {
17501 return 5;
17502 }
17503 125 }
17504 else
17505 {
17506 4 temp_map_count=map_count;
17507 }
17508
17509
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17510 {
17511 return qe_invalid;
17512 }
17513
17514 129 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17515 129 TheMaps.resize(_mapsSize);
17516 129 map_autolayers.clear();
17517 129 map_autolayers.resize(temp_map_count*6);
17518
17519
2/2
✓ Branch 0 taken 264792 times.
✓ Branch 1 taken 129 times.
264921 for(int32_t i(0); i<_mapsSize; i++)
17520 264792 TheMaps[i].zero_memory();
17521
17522 129 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17523
17524 129 temp_mapscr.zero_memory();
17525
17526 { //Is this stuff even needed anymore? Is it used at all? -Em
17527 129 memset(&temp_map, 0, sizeof(zcmap));
17528 129 temp_map.scrResWidth = 256;
17529 129 temp_map.scrResHeight = 224;
17530 129 temp_map.tileWidth = 16;
17531 129 temp_map.tileHeight = 11;
17532 129 temp_map.viewWidth = 256;
17533 129 temp_map.viewHeight = 176;
17534 129 temp_map.viewX = 0;
17535 129 temp_map.viewY = 64;
17536 129 temp_map.subaWidth = 256;
17537 129 temp_map.subaHeight = 168;
17538 129 temp_map.subaTrans = false;
17539 129 temp_map.subpWidth = 256;
17540 129 temp_map.subpHeight = 56;
17541 129 temp_map.subpTrans = false;
17542 }
17543
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1947 times.
✓ Branch 2 taken 1947 times.
✓ Branch 3 taken 129 times.
2076 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17544 {
17545 //!TODO Trim fully
17546 1947 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17547
17548 1947 byte valid=1;
17549
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 128 times.
1947 if(version > 22)
17550 {
17551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!p_getc(&valid,f))
17552 return qe_invalid;
17553 128 }
17554
4/4
✓ Branch 0 taken 1940 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1902 times.
✓ Branch 3 taken 38 times.
1947 if(valid && version > 25)
17555 {
17556
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 38 times.
266 for(int q = 0; q < 6; ++q)
17557 {
17558
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(!p_igetw(&map_autolayers[i*6+q],f))
17559 return qe_invalid;
17560 228 }
17561 38 }
17562
2/2
✓ Branch 0 taken 264584 times.
✓ Branch 1 taken 1947 times.
266531 for(int32_t j=0; j<screens_to_read; j++)
17563 {
17564 264584 scr=i*MAPSCRS+j;
17565 264584 clear_screen(&temp_mapscr);
17566
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 263632 times.
264584 if(valid)
17567 263632 readmapscreen(f, Header, &temp_mapscr, &temp_map, version, scr);
17568
17569 264584 TheMaps[scr] = temp_mapscr;
17570 264584 }
17571
17572
3/6
✓ Branch 0 taken 1895 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1947 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17573 {
17574 52 int32_t index = (i*MAPSCRS+132);
17575
17576 52 TheMaps[index]=TheMaps[index-1];
17577
17578 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17579 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17580 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17581
17582
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17583 {
17584 156 scr=i*MAPSCRS+j;
17585
17586 156 TheMaps[scr].zero_memory();
17587 156 TheMaps[scr].valid = mVERSION;
17588 156 TheMaps[scr].screen_midi = -1;
17589 156 TheMaps[scr].csensitive = 1;
17590 156 }
17591 52 }
17592
17593
3/6
✓ Branch 0 taken 1895 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1947 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17594 {
17595
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17596 {
17597 7072 scr=i*MAPSCRS+j;
17598 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17599
17600
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17601 {
17602 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17603 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17604 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17605 905216 }
17606 7072 }
17607 52 }
17608 1947 }
17609 129 map_count = temp_map_count;
17610 129 clear_screen(&temp_mapscr);
17611 129 return 0;
17612 129 }
17613
17614
17615 1094437 void update_combo(newcombo& cmb, word section_version)
17616 {
17617
2/2
✓ Branch 0 taken 153720 times.
✓ Branch 1 taken 940717 times.
1094437 if(section_version < 40)
17618 {
17619
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17620 {
17621 case cWATER: case cSHALLOWWATER:
17622 14209 cmb.attribytes[6] = iwRipples;
17623 14209 break;
17624 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17625 1389 cmb.attribytes[6] = iwTallGrass;
17626 1389 break;
17627 }
17628 940717 }
17629 1094437 }
17630 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17631 {
17632 95 reset_combo_animations();
17633 95 reset_combo_animations2();
17634
17635 95 init_combo_classes();
17636
17637 // combos
17638 95 word combos_used=0;
17639 int32_t dummy;
17640 byte padding;
17641 95 newcombo temp_combo;
17642 //word section_cversion=0;
17643
17644
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17645
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201600 combobuf[q].clear();
17646
17647 // if(version > 0x192)
17648 // {
17649 // //section version info
17650 // if(!p_igetw(&section_version,f))
17651 // {
17652 // return qe_invalid;
17653 // }
17654
17655 // FFCore.quest_format[vCombos] = section_version;
17656
17657 // //al_trace("Combos version %d\n", section_version);
17658 // if(!p_igetw(&section_cversion,f))
17659 // {
17660 // return qe_invalid;
17661 // }
17662
17663 // //section size
17664 // if(!p_igetl(&dummy,f))
17665 // {
17666 // return qe_invalid;
17667 // }
17668 // }
17669
17670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17671 {
17672 combos_used=1024;
17673 }
17674
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17675 {
17676 4 combos_used=2048;
17677 4 }
17678 else
17679 {
17680
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17681 {
17682 return qe_invalid;
17683 }
17684 }
17685
17686 //finally... section data
17687
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873209 times.
873304 for(int32_t i=0; i<combos_used; i++)
17688 {
17689
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17690
17691
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17692 {
17693
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17694 {
17695 return qe_invalid;
17696 }
17697 68884 }
17698 else
17699 {
17700
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17701 {
17702 return qe_invalid;
17703 }
17704 }
17705 873209 temp_combo.o_tile = temp_combo.tile;
17706
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17707 {
17708 return qe_invalid;
17709 }
17710
17711
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17712 {
17713 return qe_invalid;
17714 }
17715
17716
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17717 {
17718 return qe_invalid;
17719 }
17720
17721
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17722 {
17723 return qe_invalid;
17724 }
17725
17726
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17727 {
17728
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17729 return qe_invalid;
17730
17731
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17732 return qe_invalid;
17733
17734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17735 {
17736
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17737 {
17738 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17739 {
17740 if(!p_getc(&padding,f))
17741 return qe_invalid;
17742 }
17743 }
17744 8192 }
17745 8192 }
17746
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17747 {
17748
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17749 return qe_invalid;
17750
17751
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17752 return qe_invalid;
17753
17754
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17755 return qe_invalid;
17756
17757
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17758 return qe_invalid;
17759
17760 //Base flag
17761
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17762
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17763 return qe_invalid;
17764
17765
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17766 {
17767
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17768 return qe_invalid;
17769
17770
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17771 return qe_invalid;
17772 399183 }
17773
17774
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17775
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17776 return qe_invalid;
17777
17778
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17779 {
17780
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17781 return qe_invalid;
17782
17783
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17784 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17785 399183 }
17786
17787
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17788 {
17789
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17790
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17791 return qe_invalid;
17792
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17793 return qe_invalid;
17794
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17795
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17796 return qe_invalid;
17797 68884 }
17798
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17799 {
17800
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17801
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17802 return qe_invalid;
17803 68884 }
17804
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17805 {
17806 for ( int32_t q = 0; q < 2; q++ )
17807 if(!p_igetl(&temp_combo.triggerflags[q],f))
17808 return qe_invalid;
17809 }
17810
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17811
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17812 return qe_invalid;
17813
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17814
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17815 return qe_invalid;
17816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17817 {
17818 if(!p_getc(&temp_combo.triggeritem,f))
17819 return qe_invalid;
17820 if(!p_getc(&temp_combo.trigtimer,f))
17821 return qe_invalid;
17822 }
17823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17824 if(!p_getc(&temp_combo.trigsfx,f))
17825 return qe_invalid;
17826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17827 if(!p_igetl(&temp_combo.trigchange,f))
17828 return qe_invalid;
17829
17830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17831 {
17832 if(!p_igetw(&temp_combo.trigprox,f))
17833 return qe_invalid;
17834 if(!p_getc(&temp_combo.trigctr,f))
17835 return qe_invalid;
17836 if(!p_igetl(&temp_combo.trigctramnt,f))
17837 return qe_invalid;
17838 }
17839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17840 if(!p_getc(&temp_combo.triglbeam,f))
17841 return qe_invalid;
17842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17843 {
17844 if(!p_getc(&temp_combo.trigcschange,f))
17845 return qe_invalid;
17846 if(!p_igetw(&temp_combo.spawnitem,f))
17847 return qe_invalid;
17848 if(!p_igetw(&temp_combo.spawnenemy,f))
17849 return qe_invalid;
17850 if(!p_getc(&temp_combo.exstate,f))
17851 return qe_invalid;
17852 if(!p_igetl(&temp_combo.spawnip,f))
17853 return qe_invalid;
17854 if(!p_getc(&temp_combo.trigcopycat,f))
17855 return qe_invalid;
17856 }
17857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17858 if(!p_getc(&temp_combo.trigcooldown,f))
17859 return qe_invalid;
17860
17861
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17862 {
17863 char label[12];
17864 68884 label[11] = '\0';
17865
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17866
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17867 return qe_invalid;
17868
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17869 68884 }
17870
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17871
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17872
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17873 68884 return qe_invalid;
17874 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17875 * This fixes a poor implementation of a ->next flag bug thing.
17876 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17877 * there was a version bump a few weeks before a change that broke stuff.
17878 */
17879
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17880 {
17881 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17882 }
17883 //combo scripts
17884
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17885 {
17886
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17887 return qe_invalid;
17888
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17889
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17890 return qe_invalid;
17891 68884 }
17892 //al_trace("Read combo script data\n");
17893
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17894 {
17895
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17896
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17897
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17898
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17899 68884 }
17900
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17901 {
17902
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17903
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17904 return qe_invalid;
17905
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17906
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17907 return qe_invalid;
17908 68884 }
17909
17910
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17911 for(int32_t q=0; q<11; q++)
17912 if(!p_getc(&dummy,f))
17913 return qe_invalid;
17914 865017 }
17915
17916 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17917
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17918 {
17919
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17920 {
17921
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17922 {
17923 case 130:
17924 temp_combo.tile = 132;
17925 break;
17926
17927 case 131:
17928 temp_combo.tile = 133;
17929 break;
17930
17931 case 132:
17932 temp_combo.tile = 130;
17933 break;
17934
17935 case 133:
17936 temp_combo.tile = 131;
17937 break;
17938 }
17939 8192 }
17940 474026 }
17941
17942
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17943 804325 temp_combo.o_tile = temp_combo.tile;
17944
17945
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17946 804325 temp_combo.walk |= 0xF0;
17947
17948
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17949
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17950 4021625 temp_combo.attributes[q] *= 10000L;
17951
17952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17953 {
17954
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17955 {
17956 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17957 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17958 case cTRIGGERGENERIC: case cCSWITCH:
17959 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17960 384 }
17961 873209 }
17962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17963 {
17964
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17965 {
17966 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17968 3061 temp_combo.attribytes[3] = WAV_DOOR;
17969 3061 temp_combo.usrflags &= ~cflag3;
17970 3061 break;
17971 }
17972 873209 }
17973
17974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17975
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17976
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17977 temp_combo.usrflags |= cflag3;
17978
17979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17980 {
17981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17982 temp_combo.trigchange = 1;
17983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17984 temp_combo.trigchange = -1;
17985 873209 else temp_combo.trigchange = 0;
17986 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17987 873209 }
17988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17989 {
17990
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17991 {
17992 case cLOCKBLOCK: case cLOCKEDCHEST:
17993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17994 temp_combo.usrflags |= cflag8;
17995 1689 else temp_combo.usrflags &= ~cflag8;
17996 1689 temp_combo.usrflags &= ~cflag7;
17997 1689 break;
17998 }
17999
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
18000 {
18001 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18002 69 temp_combo.attrishorts[2] = -1;
18003 69 temp_combo.usrflags |= cflag7;
18004 69 break;
18005 }
18006 873209 }
18007
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
18008 {
18009 804325 temp_combo.genflags = 0;
18010
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
18011 {
18012 case cPUSH_WAIT: case cPUSH_HEAVY:
18013 case cPUSH_HW: case cL_STATUE:
18014 case cR_STATUE: case cPUSH_HEAVY2:
18015 case cPUSH_HW2: case cPOUND:
18016 case cC_STATUE: case cMIRROR:
18017 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18018 case cMAGICPRISM: case cMAGICPRISM4:
18019 case cMAGICSPONGE: case cEYEBALL_A:
18020 case cEYEBALL_B: case cEYEBALL_4:
18021 case cBUSH: case cFLOWERS:
18022 case cLOCKBLOCK: case cLOCKBLOCK2:
18023 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18024 case cCHEST: case cCHEST2:
18025 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18026 case cBOSSCHEST: case cBOSSCHEST2:
18027 case cBUSHNEXT: case cBUSHTOUCHY:
18028 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18029 case cSIGNPOST: case cCSWITCHBLOCK:
18030 case cTORCH: case cTRIGGERGENERIC:
18031
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
18032 {
18033 temp_combo.genflags |= cflag1;
18034 temp_combo.usrflags &= ~cflag16;
18035 }
18036 19291 break;
18037 }
18038 804325 }
18039
18040 873209 update_combo(temp_combo, section_version);
18041
18042
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(i>=start_combo)
18043 {
18044
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
18045 873209 }
18046 873209 }
18047
18048
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18049 {
18050
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18051 {
18052
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18053 {
18054 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18055 }
18056 261120 }
18057 4 }
18058
18059 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18060
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_zquest())
18061 {
18062
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18063
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
18064 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18065 12 }
18066
18067
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
18068 {
18069
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18070 {
18071
6/9
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1043840 times.
1044480 switch(combobuf[tmpcounter].type)
18072 {
18073 case cSLASH:
18074 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
18075 250 break;
18076
18077 case cSLASHITEM:
18078 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18079 174 break;
18080
18081 case cBUSH:
18082 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
18083 126 break;
18084
18085 case cFLOWERS:
18086 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18087 45 break;
18088
18089 case cTALLGRASS:
18090 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18091 45 break;
18092
18093 case cSLASHNEXT:
18094 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18095 break;
18096
18097 case cSLASHNEXTITEM:
18098 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18099 break;
18100
18101 case cBUSHNEXT:
18102 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18103 break;
18104 }
18105 1044480 }
18106 16 }
18107
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
18108 {
18109
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18110 {
18111
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
18112 {
18113 8054 combobuf[tmpcounter].attributes[0] = 40000L;
18114 8054 }
18115 6071040 }
18116 93 }
18117
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18118 {
18119 1 combobuf[0].walk = 0xF0;
18120 1 combobuf[0].type = 0;
18121 1 combobuf[0].flag = 0;
18122 1 }
18123
18124 //Now for the new combo alias reset
18125
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
18126 {
18127
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18128 {
18129 131072 combo_aliases[j].width = 0;
18130 131072 combo_aliases[j].height = 0;
18131 131072 combo_aliases[j].layermask = 0;
18132
18133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
18134 {
18135
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].combos;
18136 131072 }
18137
18138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
18139 {
18140
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].csets;
18141 131072 }
18142
18143
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
18144
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
18145 131072 combo_aliases[j].combos[0] = 0;
18146 131072 combo_aliases[j].csets[0] = 0;
18147 131072 }
18148 16 }
18149
18150
18151
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
18152
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
18153 95 return 0;
18154 95 }
18155 221228 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18156 {
18157 byte combo_has_flags;
18158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221228 times.
221228 if(!p_getc(&combo_has_flags,f))
18159 return qe_invalid;
18160
18161 221228 temp_combo.clear();
18162
2/2
✓ Branch 0 taken 144925 times.
✓ Branch 1 taken 76303 times.
221228 if(combo_has_flags)
18163 {
18164
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76300 times.
76303 if(combo_has_flags&CHAS_BASIC)
18165 {
18166
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_igetl(&temp_combo.tile,f))
18167 {
18168 return qe_invalid;
18169 }
18170 76300 temp_combo.o_tile = temp_combo.tile;
18171
18172
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.flip,f))
18173 {
18174 return qe_invalid;
18175 }
18176
18177
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.walk,f))
18178 {
18179 return qe_invalid;
18180 }
18181
18182
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.type,f))
18183 {
18184 return qe_invalid;
18185 }
18186
18187
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.flag,f))
18188 {
18189 return qe_invalid;
18190 }
18191
18192
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.csets,f))
18193 {
18194 return qe_invalid;
18195 }
18196 76300 }
18197
2/2
✓ Branch 0 taken 76280 times.
✓ Branch 1 taken 23 times.
76303 if(combo_has_flags&CHAS_SCRIPT)
18198 {
18199
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18200 {
18201 8 p_getcstr(&temp_combo.label, f);
18202 8 }
18203 else
18204 {
18205 char label[12];
18206 15 label[11] = '\0';
18207
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18208 {
18209
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
18210 {
18211 return qe_invalid;
18212 }
18213 165 }
18214 15 temp_combo.label = label;
18215 }
18216
18217
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18218
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18219 {
18220
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f))
18221 {
18222 return qe_invalid;
18223 }
18224 46 }
18225 23 }
18226
2/2
✓ Branch 0 taken 56050 times.
✓ Branch 1 taken 20253 times.
76303 if(combo_has_flags&CHAS_ANIM)
18227 {
18228
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.frames,f))
18229 {
18230 return qe_invalid;
18231 }
18232
18233
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.speed,f))
18234 {
18235 return qe_invalid;
18236 }
18237
18238
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_igetw(&temp_combo.nextcombo,f))
18239 {
18240 return qe_invalid;
18241 }
18242
18243
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.nextcset,f))
18244 {
18245 return qe_invalid;
18246 }
18247
18248
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.skipanim,f))
18249 {
18250 return qe_invalid;
18251 }
18252
18253
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.skipanimy,f))
18254 {
18255 return qe_invalid;
18256 }
18257
18258
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.animflags,f))
18259 {
18260 return qe_invalid;
18261 }
18262 20253 }
18263
2/2
✓ Branch 0 taken 65991 times.
✓ Branch 1 taken 10312 times.
76303 if(combo_has_flags&CHAS_ATTRIB)
18264 {
18265
2/2
✓ Branch 0 taken 41248 times.
✓ Branch 1 taken 10312 times.
51560 for ( int32_t q = 0; q < 4; q++ )
18266 {
18267
1/2
✓ Branch 0 taken 41248 times.
✗ Branch 1 not taken.
41248 if(!p_igetl(&temp_combo.attributes[q],f))
18268 {
18269 return qe_invalid;
18270 }
18271 41248 }
18272
2/2
✓ Branch 0 taken 82496 times.
✓ Branch 1 taken 10312 times.
92808 for ( int32_t q = 0; q < 8; q++ )
18273 {
18274
1/2
✓ Branch 0 taken 82496 times.
✗ Branch 1 not taken.
82496 if(!p_getc(&temp_combo.attribytes[q],f))
18275 {
18276 return qe_invalid;
18277 }
18278 82496 }
18279
2/2
✓ Branch 0 taken 82496 times.
✓ Branch 1 taken 10312 times.
92808 for ( int32_t q = 0; q < 8; q++ )
18280 {
18281
1/2
✓ Branch 0 taken 82496 times.
✗ Branch 1 not taken.
82496 if(!p_igetw(&temp_combo.attrishorts[q],f))
18282 {
18283 return qe_invalid;
18284 }
18285 82496 }
18286 10312 }
18287
2/2
✓ Branch 0 taken 74121 times.
✓ Branch 1 taken 2182 times.
76303 if(combo_has_flags&CHAS_FLAG)
18288 {
18289
1/2
✓ Branch 0 taken 2182 times.
✗ Branch 1 not taken.
2182 if(!p_igetl(&temp_combo.usrflags,f))
18290 {
18291 return qe_invalid;
18292 }
18293
1/2
✓ Branch 0 taken 2182 times.
✗ Branch 1 not taken.
2182 if(!p_igetw(&temp_combo.genflags,f))
18294 {
18295 return qe_invalid;
18296 }
18297 2182 }
18298
2/2
✓ Branch 0 taken 75530 times.
✓ Branch 1 taken 773 times.
76303 if(combo_has_flags&CHAS_TRIG)
18299 {
18300 773 int numtrigs = s_version < 36 ? 3 : 6;
18301
2/2
✓ Branch 0 taken 4209 times.
✓ Branch 1 taken 773 times.
4982 for ( int32_t q = 0; q < numtrigs; q++ )
18302 {
18303
1/2
✓ Branch 0 taken 4209 times.
✗ Branch 1 not taken.
4209 if(!p_igetl(&temp_combo.triggerflags[q],f))
18304 {
18305 return qe_invalid;
18306 }
18307 4209 }
18308
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.triggerlevel,f))
18309 {
18310 return qe_invalid;
18311 }
18312
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triggerbtn,f))
18313 {
18314 return qe_invalid;
18315 }
18316
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triggeritem,f))
18317 {
18318 return qe_invalid;
18319 }
18320
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigtimer,f))
18321 {
18322 return qe_invalid;
18323 }
18324
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigsfx,f))
18325 {
18326 return qe_invalid;
18327 }
18328
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.trigchange,f))
18329 {
18330 return qe_invalid;
18331 }
18332
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.trigprox,f))
18333 {
18334 return qe_invalid;
18335 }
18336
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigctr,f))
18337 {
18338 return qe_invalid;
18339 }
18340
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.trigctramnt,f))
18341 {
18342 return qe_invalid;
18343 }
18344
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triglbeam,f))
18345 {
18346 return qe_invalid;
18347 }
18348
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcschange,f))
18349 {
18350 return qe_invalid;
18351 }
18352
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.spawnitem,f))
18353 {
18354 return qe_invalid;
18355 }
18356
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.spawnenemy,f))
18357 {
18358 return qe_invalid;
18359 }
18360
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.exstate,f))
18361 {
18362 return qe_invalid;
18363 }
18364
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.spawnip,f))
18365 {
18366 return qe_invalid;
18367 }
18368
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcopycat,f))
18369 {
18370 return qe_invalid;
18371 }
18372
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcooldown,f))
18373 {
18374 return qe_invalid;
18375 }
18376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 773 times.
773 if(s_version >= 35)
18377 {
18378
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_cid,f))
18379 {
18380 return qe_invalid;
18381 }
18382
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.prompt_cs,f))
18383 {
18384 return qe_invalid;
18385 }
18386
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_x,f))
18387 {
18388 return qe_invalid;
18389 }
18390
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_y,f))
18391 {
18392 return qe_invalid;
18393 }
18394 773 }
18395
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 630 times.
773 if(s_version >= 36)
18396 {
18397
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&temp_combo.trig_lstate,f))
18398 {
18399 return qe_invalid;
18400 }
18401
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&temp_combo.trig_gstate,f))
18402 {
18403 return qe_invalid;
18404 }
18405
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetl(&temp_combo.trig_statetime,f))
18406 {
18407 return qe_invalid;
18408 }
18409 630 }
18410
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 630 times.
773 if(s_version >= 37)
18411 {
18412
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetw(&temp_combo.trig_genscr,f))
18413 {
18414 return qe_invalid;
18415 }
18416 630 }
18417
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 556 times.
773 if(s_version >= 38)
18418 {
18419
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(!p_getc(&temp_combo.trig_group,f))
18420 {
18421 return qe_invalid;
18422 }
18423
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(!p_igetw(&temp_combo.trig_group_val,f))
18424 {
18425 return qe_invalid;
18426 }
18427 556 }
18428 773 }
18429
2/2
✓ Branch 0 taken 76160 times.
✓ Branch 1 taken 143 times.
76303 if(combo_has_flags&CHAS_LIFT)
18430 {
18431
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftcmb,f))
18432 return qe_invalid;
18433
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftcs,f))
18434 return qe_invalid;
18435
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftundercmb,f))
18436 return qe_invalid;
18437
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftundercs,f))
18438 return qe_invalid;
18439
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftdmg,f))
18440 return qe_invalid;
18441
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftlvl,f))
18442 return qe_invalid;
18443
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftitm,f))
18444 return qe_invalid;
18445
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftflags,f))
18446 return qe_invalid;
18447
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftgfx,f))
18448 return qe_invalid;
18449
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftsprite,f))
18450 return qe_invalid;
18451
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftsfx,f))
18452 return qe_invalid;
18453
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18454 return qe_invalid;
18455
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftbreaksfx,f))
18456 return qe_invalid;
18457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(s_version >= 34)
18458 {
18459
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.lifthei,f))
18460 return qe_invalid;
18461
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.lifttime,f))
18462 return qe_invalid;
18463 143 }
18464
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 136 times.
143 if(s_version >= 39)
18465 {
18466
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(!p_getc(&temp_combo.lift_parent_item,f))
18467 return qe_invalid;
18468 136 }
18469 143 }
18470
2/2
✓ Branch 0 taken 76211 times.
✓ Branch 1 taken 92 times.
76303 if(combo_has_flags&CHAS_GENERAL)
18471 {
18472
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&temp_combo.speed_mult,f))
18473 return qe_invalid;
18474
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&temp_combo.speed_div,f))
18475 return qe_invalid;
18476
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetzf(&temp_combo.speed_add,f))
18477 return qe_invalid;
18478
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 76 times.
92 if(s_version >= 42)
18479 {
18480
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_appear,f))
18481 return qe_invalid;
18482
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_disappear,f))
18483 return qe_invalid;
18484
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_loop,f))
18485 return qe_invalid;
18486
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_walking,f))
18487 return qe_invalid;
18488
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_standing,f))
18489 return qe_invalid;
18490
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_appear,f))
18491 return qe_invalid;
18492
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_disappear,f))
18493 return qe_invalid;
18494
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_walking,f))
18495 return qe_invalid;
18496
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_standing,f))
18497 return qe_invalid;
18498 76 }
18499 92 }
18500 76303 }
18501 221228 update_combo(temp_combo, s_version);
18502 221228 return 0;
18503 221228 }
18504 129 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18505 {
18506 129 word section_version=0;
18507 129 word section_cversion=0;
18508 129 word combos_used=0;
18509 int32_t dummy;
18510 byte padding;
18511 129 newcombo temp_combo;
18512
18513
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations();
18514
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations2();
18515
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_combo_classes();
18516
18517
2/2
✓ Branch 0 taken 8421120 times.
✓ Branch 1 taken 129 times.
8421249 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18518
1/2
✓ Branch 0 taken 8421120 times.
✗ Branch 1 not taken.
8421120 combobuf[q].clear();
18519
18520
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(version > 0x192) //Version info
18521 {
18522
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_version,f))
18523 {
18524 return qe_invalid;
18525 }
18526 125 FFCore.quest_format[vCombos] = section_version;
18527
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_cversion,f))
18528 {
18529 return qe_invalid;
18530 }
18531
18532 //section size
18533
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
18534 {
18535 return qe_invalid;
18536 }
18537 125 }
18538
18539
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(section_version > 32) //Cleanup time!
18540 {
18541
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&combos_used,f))
18542 {
18543 return qe_invalid;
18544 }
18545
2/2
✓ Branch 0 taken 221228 times.
✓ Branch 1 taken 34 times.
221262 for(int32_t i=0; i<combos_used; i++)
18546 {
18547
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 auto ret = readcombo_loop(f,section_version,temp_combo);
18548
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 if(ret) return ret;
18549
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 if(i>=start_combo)
18550
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 combobuf[i] = temp_combo;
18551 221228 }
18552 34 }
18553 else //Call the old function for all old versions
18554 {
18555
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18556
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if(ret) return ret; //error, end read
18557 }
18558
18559
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 33 times.
129 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18560 {
18561 33 combobuf[0].walk = 0xF0;
18562 33 combobuf[0].type = 0;
18563 33 combobuf[0].flag = 0;
18564 33 }
18565
18566
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations();
18567
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations2();
18568 129 return 0;
18569 129 }
18570
18571 113 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18572 {
18573 //these are here to bypass compiler warnings about unused arguments
18574 113 Header=Header;
18575 113 version=version;
18576 113 build=build;
18577
18578 int32_t dummy;
18579 113 word sversion=0, c_sversion;
18580
18581 //section version info
18582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&sversion,f))
18583 {
18584 return qe_invalid;
18585 }
18586
18587 113 FFCore.quest_format[vComboAliases] = sversion;
18588
18589 //al_trace("Combo aliases version %d\n", sversion);
18590
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&c_sversion,f))
18591 {
18592 return qe_invalid;
18593 }
18594
18595 //section size
18596
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
18597 {
18598 return qe_invalid;
18599 }
18600
18601 113 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18602
18603
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18604 {
18605 77 max_num_combo_aliases = MAX250COMBOALIASES;
18606 77 }
18607
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18608 {
18609 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18610 }
18611
18612
2/2
✓ Branch 0 taken 452608 times.
✓ Branch 1 taken 113 times.
452721 for(int32_t j=0; j<max_num_combo_aliases; j++)
18613 {
18614 byte width,height,mask,tempcset;
18615 int32_t count;
18616 word tempword;
18617 byte tempbyte;
18618
18619
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_igetw(&tempword,f))
18620 {
18621 return qe_invalid;
18622 }
18623
18624 452608 combo_aliases[j].combo = tempword;
18625
18626
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&tempbyte,f))
18627 {
18628 return qe_invalid;
18629 }
18630
18631 452608 combo_aliases[j].cset = tempbyte;
18632
18633
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&width,f))
18634 {
18635 return qe_invalid;
18636 }
18637
18638
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&height,f))
18639 {
18640 return qe_invalid;
18641 }
18642
18643
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&mask,f))
18644 {
18645 return qe_invalid;
18646 }
18647
18648 452608 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18649
18650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].combos != NULL)
18651 {
18652
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].combos;
18653 452608 }
18654
18655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].csets != NULL)
18656 {
18657
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].csets;
18658 452608 }
18659
18660 452608 combo_aliases[j].width = width;
18661 452608 combo_aliases[j].height = height;
18662 452608 combo_aliases[j].layermask = mask;
18663 452608 combo_aliases[j].combos = new word[count];
18664 452608 combo_aliases[j].csets = new byte[count];
18665
18666
2/2
✓ Branch 0 taken 463821 times.
✓ Branch 1 taken 452608 times.
916429 for(int32_t k=0; k<count; k++)
18667 {
18668
1/2
✓ Branch 0 taken 463821 times.
✗ Branch 1 not taken.
463821 if(!p_igetw(&tempword,f))
18669 {
18670 return qe_invalid;
18671 }
18672
18673 463821 combo_aliases[j].combos[k] = tempword;
18674 463821 }
18675
18676
2/2
✓ Branch 0 taken 463821 times.
✓ Branch 1 taken 452608 times.
916429 for(int32_t k=0; k<count; k++)
18677 {
18678
1/2
✓ Branch 0 taken 463821 times.
✗ Branch 1 not taken.
463821 if(!p_getc(&tempcset,f))
18679 {
18680 return qe_invalid;
18681 }
18682
18683 463821 combo_aliases[j].csets[k] = tempcset;
18684 463821 }
18685 452608 }
18686
18687 113 word num_combo_pools = 0;
18688
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 34 times.
113 if(sversion >= 4)
18689 {
18690
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(!p_igetw(&num_combo_pools,f))
18691 {
18692 return qe_invalid;
18693 }
18694 34 }
18695
18696
2/2
✓ Branch 0 taken 925696 times.
✓ Branch 1 taken 113 times.
925809 for(combo_pool& pool : combo_pools)
18697 {
18698 925696 pool.clear();
18699 }
18700
18701 113 combo_pool temp_cpool;
18702
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 113 times.
206 for(word cp = 0; cp < num_combo_pools; ++cp)
18703 {
18704 93 int32_t num_combos_in_pool = 0;
18705
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(!p_igetl(&num_combos_in_pool,f))
18706 {
18707 return qe_invalid;
18708 }
18709
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(num_combos_in_pool < 1) continue; //nothing to read
18710
18711
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_cpool.clear();
18712
18713 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18714
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 403 times.
496 for(auto q = 0; q < num_combos_in_pool; ++q)
18715 {
18716
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&cp_cid,f))
18717 {
18718 return qe_invalid;
18719 }
18720
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&cp_cs,f))
18721 {
18722 return qe_invalid;
18723 }
18724
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&cp_quant,f))
18725 {
18726 return qe_invalid;
18727 }
18728
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18729 403 }
18730
18731
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 combo_pools[cp] = temp_cpool;
18732 93 }
18733
18734 113 return 0;
18735 113 }
18736
18737 129 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18738 {
18739 //these are here to bypass compiler warnings about unused arguments
18740
18741 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18742 //Capitalized cause it'll save you a headache. -Deedee
18743 129 start_cset=start_cset;
18744 129 max_csets=max_csets;
18745 129 word s_version=0;
18746
18747 miscQdata temp_misc;
18748 129 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18749
18750 byte temp_colordata[48];
18751 char temp_palname[PALNAMESIZE];
18752
18753 int32_t dummy;
18754 word palcycles;
18755
18756
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18757 {
18758 //section version info
18759
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
18760 {
18761 return qe_invalid;
18762 }
18763
18764 125 FFCore.quest_format[vCSets] = s_version;
18765
18766 //al_trace("Color data version %d\n", s_version);
18767
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
18768 {
18769 return qe_invalid;
18770 }
18771
18772 //section size
18773
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
18774 {
18775 return qe_invalid;
18776 }
18777 125 }
18778
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if (s_version < 5)
18779 {
18780
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18781
18782 //finally... section data
18783 93 int32_t q = 0;
18784 93 int32_t p = -15;
18785
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18786 {
18787 22320 memset(temp_colordata, 0, 48);
18788
18789
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18790 {
18791 return qe_invalid;
18792 }
18793
18794 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18795
18796 22320 ++q;
18797
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18798 {
18799
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18800 {
18801 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18802 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18803 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18804 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18805 1573 q+=4;
18806 1573 }
18807 else
18808 {
18809 for(int m = 0; m < 4; ++m)
18810 {
18811 memset(temp_colordata, 0, 48);
18812 if(!pfread(temp_colordata,48,f))
18813 {
18814 return qe_invalid;
18815 }
18816 memcpy(&colordata[q*48], temp_colordata, 48);
18817 ++q;
18818 }
18819 }
18820 1573 }
18821 22320 ++p;
18822 22320 }
18823
18824
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18825 {
18826 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18827 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18828 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18829 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18830 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18831 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18832 4 }
18833 else
18834 {
18835 89 memset(temp_colordata, 0, 48);
18836
18837
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18838 {
18839
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18840 {
18841 return qe_invalid;
18842 }
18843
18844 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18845
18846 278837 ++q;
18847
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18848 {
18849
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18850 {
18851 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18852 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18853 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18854 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18855 21425 q+=4;
18856 21425 }
18857 else
18858 {
18859 for(int m = 0; m < 4; ++m)
18860 {
18861 memset(temp_colordata, 0, 48);
18862 if(!pfread(temp_colordata,48,f))
18863 {
18864 return qe_invalid;
18865 }
18866 memcpy(&colordata[q*48], temp_colordata, 48);
18867 ++q;
18868 }
18869 }
18870 21425 }
18871 278837 ++p;
18872 278837 }
18873
18874
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18875 {
18876 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18877 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18878 12 }
18879 else
18880 {
18881
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18882 {
18883
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18884 {
18885 return qe_invalid;
18886 }
18887
18888 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18889 256256 ++q;
18890
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18891 {
18892
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18893 {
18894 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18895 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18896 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18897 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18898 19558 q+=4;
18899 19558 }
18900 else
18901 {
18902 for(int m = 0; m < 4; ++m)
18903 {
18904 memset(temp_colordata, 0, 48);
18905 if(!pfread(temp_colordata,48,f))
18906 {
18907 return qe_invalid;
18908 }
18909 memcpy(&colordata[q*48], temp_colordata, 48);
18910 ++q;
18911 }
18912 }
18913 19558 }
18914 256256 ++p;
18915 256256 }
18916
18917 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18918 }
18919 }
18920 93 }
18921 else
18922 {
18923
2/2
✓ Branch 0 taken 314964 times.
✓ Branch 1 taken 36 times.
315000 for(int32_t i=0; i<pdTOTAL255; ++i)
18924 {
18925 314964 memset(temp_colordata, 0, 48);
18926
18927
1/2
✓ Branch 0 taken 314964 times.
✗ Branch 1 not taken.
314964 if(!pfread(temp_colordata,48,f))
18928 {
18929 return qe_invalid;
18930 }
18931
18932 314964 memcpy(&colordata[i*48], temp_colordata, 48);
18933 314964 }
18934 }
18935
18936
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)||((version == 0x192)&&(build<76)))
18937 {
18938 4 init_palnames();
18939 4 }
18940 else
18941 {
18942 125 int32_t palnamestoread = 0;
18943
18944
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 3)
18945 12 palnamestoread = OLDMAXLEVELS;
18946 else
18947 113 palnamestoread = 512;
18948
18949
2/2
✓ Branch 0 taken 60928 times.
✓ Branch 1 taken 125 times.
61053 for(int32_t i=0; i<palnamestoread; ++i)
18950 {
18951 60928 memset(temp_palname, 0, PALNAMESIZE);
18952
18953
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(temp_palname,PALNAMESIZE,f))
18954 {
18955 return qe_invalid;
18956 }
18957
18958 60928 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18959 60928 }
18960
18961
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 125 times.
3197 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18962 {
18963 3072 memset(palnames[i], 0, PALNAMESIZE);
18964 3072 }
18965 }
18966
18967
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18968 {
18969
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<256; i++)
18970 {
18971
2/2
✓ Branch 0 taken 96000 times.
✓ Branch 1 taken 32000 times.
128000 for(int32_t j=0; j<3; j++)
18972 {
18973 96000 temp_misc.cycles[i][j].first=0;
18974 96000 temp_misc.cycles[i][j].count=0;
18975 96000 temp_misc.cycles[i][j].speed=0;
18976 96000 }
18977 32000 }
18978
18979
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&palcycles,f))
18980 {
18981 return qe_invalid;
18982 }
18983
18984
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18985 {
18986 return qe_invalid;
18987 }
18988
18989
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 125 times.
3701 for(int32_t i=0; i<palcycles; i++)
18990 {
18991
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18992 {
18993
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18994 {
18995 return qe_invalid;
18996 }
18997 10728 }
18998
18999
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
19000 {
19001
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19002 {
19003 return qe_invalid;
19004 }
19005 10728 }
19006
19007
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
19008 {
19009
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19010 {
19011 return qe_invalid;
19012 }
19013 10728 }
19014 3576 }
19015
19016 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19017 125 }
19018
19019 129 return 0;
19020 129 }
19021
19022 129 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19023 {
19024 129 int32_t tiles_used=0;
19025 129 word section_version = 0;
19026 129 word section_cversion = 0;
19027 129 int32_t section_size= 0;
19028 129 byte *temp_tile = new byte[tilesize(tf32Bit)];
19029
19030 //Tile Expansion
19031 //if ( version >= 0x254 && build >= 41 )
19032
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
129 if (version < 0x254 && build < 41)
19033 {
19034 //al_trace("Build was < 41 when reading tiles\n");
19035 93 max_tiles = ZC250MAXTILES;
19036 93 }
19037
19038 //al_trace("Max Tiles: %d\n", max_tiles);
19039
19040
2/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19041 {
19042 if(!init_tiles(true, Header))
19043 {
19044 al_trace("Unable to initialize tiles\n");
19045 }
19046
19047 delete[] temp_tile;
19048 temp_tile=NULL;
19049 return 0;
19050 }
19051 else
19052 {
19053
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
19054 {
19055 //section version info
19056
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
19057 {
19058 delete[] temp_tile;
19059 return qe_invalid;
19060 }
19061
19062 125 FFCore.quest_format[vTiles] = section_version;
19063
19064
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_cversion,f))
19065 {
19066 delete[] temp_tile;
19067 return qe_invalid;
19068 }
19069
19070 //section size
19071
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
19072 {
19073 delete[] temp_tile;
19074 return qe_invalid;
19075 }
19076 125 }
19077
19078 //if ( build < 41 )
19079 //{
19080 // tiles_used = ZC250MAXTILES;
19081 //}
19082
19083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(version < 0x174)
19084 {
19085 tiles_used=TILES_PER_PAGE*4;
19086 } //no expanded tile space
19087
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 else if(version < 0x191)
19088 {
19089 4 tiles_used=OLDMAXTILES;
19090 4 }
19091 else
19092 {
19093 //finally... section data
19094
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
125 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19095 {
19096
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tiles_used,f))
19097 {
19098 delete[] temp_tile;
19099 return qe_invalid;
19100 }
19101 36 }
19102 else
19103 {
19104
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
19105 {
19106 delete[] temp_tile;
19107 return qe_invalid;
19108 }
19109 }
19110 }
19111
19112
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 tiles_used=zc_min(tiles_used, max_tiles);
19113
19114 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19115 //if ( version < 0x254 && build < 41 )
19116
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( version < 0x254 || (version == 0x254 && build < 41) )
19117 //if ( build < 41 )
19118 {
19119
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19120 93 }
19121 else //2.55
19122 {
19123
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19124 }
19125
19126 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19127
19128 //al_trace("tiles_used = %d\n", tiles_used);
19129
19130
2/2
✓ Branch 0 taken 3496770 times.
✓ Branch 1 taken 129 times.
3496899 for(int32_t i=0; i<tiles_used; ++i)
19131 {
19132 3496770 byte format=tf4Bit;
19133 3496770 memset(temp_tile, 0, tilesize(tf32Bit));
19134
19135
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2865990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3496770 if((version>0x211)||((version==0x211)&&(build>4)))
19136 {
19137
1/2
✓ Branch 0 taken 2865990 times.
✗ Branch 1 not taken.
2865990 if(!p_getc(&format,f))
19138 {
19139 delete[] temp_tile;
19140 return qe_invalid;
19141 }
19142 2865990 }
19143
4/4
✓ Branch 0 taken 1316436 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 612691 times.
✓ Branch 3 taken 703745 times.
3496770 if(section_version > 2 && !format)
19144 {
19145 703745 reset_tile(buf,start_tile+i,tf4Bit);
19146 703745 continue;
19147 }
19148
19149
1/2
✓ Branch 0 taken 2793025 times.
✗ Branch 1 not taken.
2793025 if(!pfread(temp_tile,tilesize(format),f))
19150 {
19151 delete[] temp_tile;
19152 return qe_invalid;
19153 }
19154
19155 2793025 buf[start_tile+i].format=format;
19156
19157
1/2
✓ Branch 0 taken 2793025 times.
✗ Branch 1 not taken.
2793025 if(buf[start_tile+i].data)
19158 {
19159 2793025 free(buf[start_tile+i].data);
19160 2793025 buf[start_tile+i].data=NULL;
19161 2793025 }
19162
19163 2793025 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19164 2793025 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19165 2793025 }
19166 }
19167
19168
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19169 {
19170 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19171
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19172 {
19173
19174 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19175 13855140 reset_tile(buf,q,tf4Bit);
19176
19177
19178 /*
19179
19180 byte tempbyte;
19181 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19182 {
19183 tempbyte=buf[ZC250MAXTILES-1].data[i];
19184 buf[q].data[i] = tempbyte;
19185 }
19186 //int32_t temp = tempbyte=buf[130].data[i];
19187 //buf[q].data = buf[ZC250MAXTILES-1].data;
19188 */
19189 //reset_tile(buf,q,tf4Bit);
19190 13855140 }
19191
19192 93 }
19193
19194
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19195 {
19196
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19197 {
19198 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19199 4121646 reset_tile(buf,i,tf4Bit);
19200 4121646 }
19201 93 }
19202 else
19203 {
19204
2/2
✓ Branch 0 taken 6196944 times.
✓ Branch 1 taken 36 times.
6196980 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19205 {
19206 //al_trace("Resetting tiles for build 41+\n");
19207 6196944 reset_tile(buf,i,tf4Bit);
19208 6196944 }
19209 }
19210
19211
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19212 {
19213
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19214 {
19215 byte tempbyte;
19216 int32_t floattile=wpnsbuf[iwSwim].tile;
19217
19218 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19219 {
19220 tempbyte=buf[23].data[i];
19221 buf[23].data[i]=buf[24].data[i];
19222 buf[24].data[i]=buf[25].data[i];
19223 buf[25].data[i]=buf[26].data[i];
19224 buf[26].data[i]=tempbyte;
19225 }
19226 //swim tiles are out of order, too, but nobody cared? -Z
19227 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19228 {
19229 tempbyte=buf[floattile+11].data[i];
19230 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19231 buf[floattile+12].data[i]=tempbyte;
19232 }
19233 }
19234 4 }
19235
19236
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19237 {
19238
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19239 {
19240 byte tempbyte;
19241
19242
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19243 {
19244 512 tempbyte=buf[130].data[i];
19245 512 buf[130].data[i]=buf[132].data[i];
19246 512 buf[132].data[i]=tempbyte;
19247
19248 512 tempbyte=buf[131].data[i];
19249 512 buf[131].data[i]=buf[133].data[i];
19250 512 buf[133].data[i]=tempbyte;
19251 512 }
19252 4 }
19253 16 }
19254
19255 129 al_trace("Registering blank tiles\n");
19256 129 register_blank_tiles();
19257
19258 //memset(temp_tile, 0, tilesize(tf32Bit));
19259
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 delete[] temp_tile;
19260 129 temp_tile=NULL;
19261 129 return 0;
19262 129 }
19263
19264 129 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19265 {
19266 129 byte *mf=midi_flags;
19267 int32_t dummy;
19268 word dummy2;
19269 // zcmidi_ temp_midi;
19270 int32_t tunes_to_read;
19271 129 int32_t tune_count=0;
19272 129 word section_version=0;
19273 129 zctune temp;
19274
19275
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
19276 {
19277 // mf=Header->data_flags+ZQ_MIDIS2;
19278
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19279 {
19280 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19281 4 }
19282 else
19283 {
19284 tunes_to_read=MAXCUSTOMTUNES;
19285 }
19286 4 }
19287 else
19288 {
19289 //section version info
19290
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
19291 {
19292 return qe_invalid;
19293 }
19294
19295 125 FFCore.quest_format[vMIDIs] = section_version;
19296
19297 //al_trace("Tunes version %d\n", section_version);
19298
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy2,f))
19299 {
19300 return qe_invalid;
19301 }
19302
19303 //section size
19304
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19305 {
19306 return qe_invalid;
19307 }
19308
19309 //finally... section data
19310
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(midi_flags,sizeof(midi_flags),f))
19311 {
19312 return qe_invalid;
19313 }
19314
19315 125 tunes_to_read=MAXCUSTOMTUNES;
19316 }
19317
19318
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19319 {
19320
2/2
✓ Branch 0 taken 30206 times.
✓ Branch 1 taken 2302 times.
32508 if(get_bit(mf, i))
19321 {
19322 2302 ++tune_count;
19323 2302 }
19324 32508 }
19325
19326 129 reset_tunes(tunes); //reset_midis(midis);
19327
19328
2/2
✓ Branch 0 taken 31628 times.
✓ Branch 1 taken 129 times.
31757 for(int32_t i=0; i<tunes_to_read; i++)
19329 {
19330 31628 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19331
19332 31628 tunes[i].reset(); // reset_midi(midis+i);
19333
19334
2/2
✓ Branch 0 taken 29326 times.
✓ Branch 1 taken 2302 times.
31628 if(get_bit(mf,i))
19335 {
19336
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version < 4)
19337 {
19338
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19339 {
19340 return qe_invalid;
19341 }
19342 717 }
19343 else
19344 {
19345
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&temp.title,sizeof(temp.title),f))
19346 {
19347 return qe_invalid;
19348 }
19349 }
19350
19351
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.start,f))
19352 {
19353 return qe_invalid;
19354 }
19355
19356
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.loop_start,f))
19357 {
19358 return qe_invalid;
19359 }
19360
19361
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.loop_end,f))
19362 {
19363 return qe_invalid;
19364 }
19365
19366
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetw(&temp.loop,f))
19367 {
19368 return qe_invalid;
19369 }
19370
19371
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetw(&temp.volume,f))
19372 {
19373 return qe_invalid;
19374 }
19375
19376
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 78 times.
2302 if(Header->zelda_version < 0x193)
19377 {
19378
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19379 {
19380 return qe_invalid;
19381 }
19382 78 }
19383
19384
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version >= 3)
19385 {
19386
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19387 {
19388 return qe_invalid;
19389 }
19390 1585 }
19391
19392 2302 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19393
19394
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19395 {
19396 // old format - a midi is a midi
19397
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19398 {
19399 return qe_invalid;
19400 }
19401
19402 //yes you can do this. Isn't the ? operator awesome? :)
19403 717 tunes[i].format = MFORMAT_MIDI;
19404 717 }
19405 else
19406 {
19407 // 'midi' could be midi or nes, gb, ... music
19408
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19409 {
19410 return qe_invalid;
19411 }
19412
19413 1585 zctune *ptr = &tunes[i];
19414
19415
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 switch(temp.format)
19416 {
19417 case MFORMAT_MIDI:
19418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585 times.
1585 if((ptr->data=read_midi(f))==NULL)
19419 {
19420 return qe_invalid;
19421 }
19422
19423 1585 break;
19424
19425 default:
19426 return qe_invalid;
19427 break;
19428 }
19429 }
19430 2302 }
19431 31628 }
19432
19433 129 return 0;
19434 129 }
19435
19436 129 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19437 {
19438 int32_t dummy;
19439 ZCHEATS tempzcheats;
19440 129 char temp_use_cheats=1;
19441 129 memset(&tempzcheats, 0, sizeof(tempzcheats));
19442 129 word s_version = 0;
19443
19444
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
19445 {
19446 //section version info
19447
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
19448 {
19449 return qe_invalid;
19450 }
19451
19452 125 FFCore.quest_format[vCheats] = s_version;
19453 //al_trace("Cheats version %d\n", dummy);
19454
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
19455 {
19456 return qe_invalid;
19457 }
19458
19459 //section size
19460
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19461 {
19462 return qe_invalid;
19463 }
19464
19465 //finally... section data
19466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_getc(&temp_use_cheats,f))
19467 {
19468 return qe_invalid;
19469 }
19470 125 }
19471
19472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(Header->data_flags[ZQ_CHEATS2])
19473 {
19474
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_igetl(&tempzcheats.flags,f))
19475 {
19476 return qe_invalid;
19477 }
19478
19479
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19480 {
19481 return qe_invalid;
19482 }
19483 129 }
19484
19485 129 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19486 129 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19487
19488 129 return 0;
19489 129 }
19490
19491 285 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19492 {
19493 int32_t dummy;
19494 285 word s_version=0, s_cversion=0;
19495 byte padding;
19496
19497 285 zinitdata temp_zinit;
19498
19499 // Legacy item properties (now integrated into itemdata)
19500 byte sword_hearts[4];
19501 byte beam_hearts[4];
19502 285 byte beam_percent=0;
19503 word beam_power[4];
19504 285 byte hookshot_length=99;
19505 285 byte hookshot_links=100;
19506 285 byte longshot_length=99;
19507 285 byte longshot_links=100;
19508 285 byte moving_fairy_hearts=3;
19509 285 byte moving_fairy_heart_percent=0;
19510 285 byte stationary_fairy_hearts=3;
19511 285 byte stationary_fairy_heart_percent=0;
19512 285 byte moving_fairy_magic=0;
19513 285 byte moving_fairy_magic_percent=0;
19514 285 byte stationary_fairy_magic=0;
19515 285 byte stationary_fairy_magic_percent=0;
19516 285 byte blue_potion_hearts=100;
19517 285 byte blue_potion_heart_percent=1;
19518 285 byte red_potion_hearts=100;
19519 285 byte red_potion_heart_percent=1;
19520 285 byte blue_potion_magic=100;
19521 285 byte blue_potion_magic_percent=1;
19522 285 byte red_potion_magic=100;
19523 285 byte red_potion_magic_percent=1;
19524
19525
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 156 times.
285 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19526
19527
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
19528 {
19529 //section version info
19530
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
19531 {
19532 return qe_invalid;
19533 }
19534
19535 125 FFCore.quest_format[vInitData] = s_version;
19536
19537 //al_trace("Init data version %d\n", s_version);
19538
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
19539 {
19540 return qe_invalid;
19541 }
19542
19543 //section size
19544
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
19545 {
19546 return qe_invalid;
19547 }
19548 125 }
19549
19550 /* HIGHLY UNORTHODOX UPDATING THING, by L
19551 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19552 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19553 * changing from 13 to 14.
19554 */
19555
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 14)
19556 16 fixpolsvoice=true;
19557
19558 /* End highly unorthodox updating thing */
19559
19560
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 38 times.
129 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19561 38 temp_zinit.jump_hero_layer_threshold=0;
19562
19563
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version >= 10)
19564 {
19565 char temp;
19566
19567 //new-style items
19568
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t j=0; j<256; j++)
19569 {
19570
2/4
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28928 times.
28928 if(!p_getc(&temp,f))
19571 return qe_invalid;
19572
19573 28928 temp_zinit.items[j] = (temp != 0);
19574 28928 }
19575 113 }
19576
19577
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 31 times.
129 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19578 {
19579 char temp;
19580
19581 //finally... section data
19582
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 31 times.
156 if((Header->zelda_version > 0x192)||
19583 //new only
19584 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19585 {
19586 //OLD-style items... sigh
19587
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 10)
19588 {
19589
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19590 {
19591 return qe_invalid;
19592 }
19593
19594 12 temp_zinit.items[iRaft]=(temp != 0);
19595
19596
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19597 {
19598 return qe_invalid;
19599 }
19600
19601 12 temp_zinit.items[iLadder]=(temp != 0);
19602
19603
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19604 {
19605 return qe_invalid;
19606 }
19607
19608 12 temp_zinit.items[iBook]=(temp != 0);
19609
19610
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19611 {
19612 return qe_invalid;
19613 }
19614
19615 12 temp_zinit.items[iMKey]=(temp!=0);
19616
19617
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19618 {
19619 return qe_invalid;
19620 }
19621
19622 12 temp_zinit.items[iFlippers]=(temp != 0);
19623
19624
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19625 {
19626 return qe_invalid;
19627 }
19628
19629 12 temp_zinit.items[iBoots]=(temp!=0);
19630 12 }
19631 125 }
19632
19633
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
156 if(s_version < 10)
19634 {
19635 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19636
19637
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19638 {
19639 return qe_invalid;
19640 }
19641
19642
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19643 {
19644 return qe_invalid;
19645 }
19646
19647
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19648 {
19649 return qe_invalid;
19650 }
19651
19652
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19653 {
19654 return qe_invalid;
19655 }
19656
19657
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19658 {
19659 return qe_invalid;
19660 }
19661
19662
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19663 {
19664 return qe_invalid;
19665 }
19666
19667
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19668 {
19669 return qe_invalid;
19670 }
19671
19672 //old only
19673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19674 {
19675 tempring=(tempring)?(1<<(tempring-1)):0;
19676 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19677 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19678 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19679 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19680 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19681 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19682 }
19683
19684 //rings start at level 2... wtf
19685 //account for this -DD
19686 12 tempring <<= 1;
19687
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19688
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19689
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19690
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19691 //bracelet ALSO starts at level 2 :-( -DD
19692 12 tempbracelet<<=1;
19693
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19694
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19695
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19696
19697 //new only
19698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19699 {
19700 for(int32_t q=0; q<32; q++)
19701 {
19702 if(!p_getc(&padding,f))
19703 {
19704 return qe_invalid;
19705 }
19706 }
19707 }
19708
19709 char tempcandle, tempboomerang, temparrow, tempwhistle;
19710
19711
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19712 {
19713 return qe_invalid;
19714 }
19715
19716
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19717 {
19718 return qe_invalid;
19719 }
19720
19721
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19722 {
19723 return qe_invalid;
19724 }
19725
19726
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19727 {
19728 return qe_invalid;
19729 }
19730
19731
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19732
19733
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19734 {
19735 return qe_invalid;
19736 }
19737
19738 //old only
19739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19740 {
19741 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19742 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19743 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19744 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19745 }
19746
19747
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19748
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19749
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19750
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19751 //What about the potion...?
19752
19753 12 }
19754
19755
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 65 times.
154 if(s_version < 29)
19756 {
19757 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19758 //to jab out my eye...
19759
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19760 return qe_invalid;
19761 89 temp_zinit.bombs = padding;
19762
19763
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19764 return qe_invalid;
19765 89 temp_zinit.super_bombs = padding;
19766 89 }
19767
19768 //Back to more OLD item code
19769
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
154 if(s_version < 10)
19770 {
19771
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19772 //new only
19773 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19774 {
19775
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19776 {
19777 return qe_invalid;
19778 }
19779
19780
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19781
19782
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19783 {
19784 return qe_invalid;
19785 }
19786
19787
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19788
19789
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19790 {
19791 return qe_invalid;
19792 }
19793
19794
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19795
19796
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19797 {
19798 return qe_invalid;
19799 }
19800
19801
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19802
19803
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19804 {
19805 return qe_invalid;
19806 }
19807
19808
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19809
19810
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19811 {
19812 return qe_invalid;
19813 }
19814
19815
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19816
19817
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19818 {
19819 return qe_invalid;
19820 }
19821
19822
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19823
19824
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19825 {
19826 return qe_invalid;
19827 }
19828
19829
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19830
19831
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19832 {
19833 return qe_invalid;
19834 }
19835
19836
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19837
19838
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19839 {
19840 return qe_invalid;
19841 }
19842
19843
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19844 {
19845 for(int32_t q=0; q<32; q++)
19846 {
19847 if(!p_getc(&padding,f))
19848 {
19849 return qe_invalid;
19850 }
19851 }
19852 }
19853 12 }
19854 12 }
19855
19856 //old only
19857
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19858 {
19859 byte equipment, items; //bit flags
19860
19861 if(!p_getc(&equipment,f))
19862 {
19863 return qe_invalid;
19864 }
19865
19866 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19867 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19868 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19869 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19870 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19871 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19872
19873
19874 if(!p_getc(&items,f))
19875 {
19876 return qe_invalid;
19877 }
19878
19879 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19880 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19881 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19882 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19883 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19884 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19885 }
19886
19887 if(!p_getc(&temp_zinit.hc,f))
19888 {
19889 return qe_invalid;
19890 }
19891
19892
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
19893 {
19894 byte temphp;
19895
19896
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19897 {
19898 return qe_invalid;
19899 }
19900
19901 12 temp_zinit.start_heart=temphp;
19902
19903
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19904 {
19905 return qe_invalid;
19906 }
19907
19908 12 temp_zinit.cont_heart=temphp;
19909 12 }
19910 else
19911 {
19912
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_heart,f))
19913 {
19914 return qe_invalid;
19915 }
19916
19917
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.cont_heart,f))
19918 {
19919 return qe_invalid;
19920 }
19921 }
19922
19923
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.hcp,f))
19924 {
19925 return qe_invalid;
19926 }
19927
19928
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version >= 14)
19929 {
19930
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19931 {
19932 return qe_invalid;
19933 }
19934
19935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version<16) // July 2007
19936 {
19937 if(get_qr(qr_BRANGPICKUP+1))
19938 temp_zinit.hcp_per_hc = 0xFF;
19939
19940 //Dispose of legacy rule
19941 set_qr(qr_BRANGPICKUP+1, 0);
19942 }
19943 113 }
19944
19945
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 29)
19946 {
19947
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19948 return qe_invalid;
19949 89 temp_zinit.max_bombs = padding;
19950 89 }
19951
19952
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.keys,f))
19953 {
19954 return qe_invalid;
19955 }
19956
19957
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_zinit.rupies,f))
19958 {
19959 return qe_invalid;
19960 }
19961
19962
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.triforce,f))
19963 {
19964 return qe_invalid;
19965 }
19966
19967
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19968 {
19969
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19970 {
19971
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.map[i],f))
19972 {
19973 return qe_invalid;
19974 }
19975 7232 }
19976
19977
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19978 {
19979
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.compass[i],f))
19980 {
19981 return qe_invalid;
19982 }
19983 7232 }
19984 113 }
19985 else
19986 {
19987
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19988 {
19989
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19990 {
19991 return qe_invalid;
19992 }
19993 384 }
19994
19995
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19996 {
19997
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19998 {
19999 return qe_invalid;
20000 }
20001 384 }
20002 }
20003
20004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version > 0x192)||
20005 //new only
20006 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20007 {
20008
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20009 {
20010
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
20011 {
20012
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.boss_key[i],f))
20013 {
20014 return qe_invalid;
20015 }
20016 7232 }
20017 113 }
20018 else
20019 {
20020
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
20021 {
20022
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
20023 {
20024 return qe_invalid;
20025 }
20026 384 }
20027 }
20028 125 }
20029
20030
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 2000 times.
2125 for(int32_t i=0; i<16; i++)
20031 {
20032
2/4
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2000 times.
2000 if(!p_getc(&temp_zinit.misc[i],f))
20033 {
20034 return qe_invalid;
20035 }
20036 2000 }
20037
20038
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
173 if(s_version < 15) for(int32_t i=0; i<4; i++)
20039 {
20040
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
20041 {
20042 return qe_invalid;
20043 }
20044 60 }
20045
20046
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_map,f))
20047 {
20048 return qe_invalid;
20049 }
20050
20051
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_screen,f))
20052 {
20053 return qe_invalid;
20054 }
20055
20056
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
20057 {
20058 byte tempmp;
20059
20060
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20061 {
20062 return qe_invalid;
20063 }
20064
20065 12 temp_zinit.max_magic=tempmp;
20066
20067
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20068 {
20069 return qe_invalid;
20070 }
20071
20072 12 temp_zinit.magic=tempmp;
20073 12 }
20074 else
20075 {
20076
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_magic,f))
20077 {
20078 return qe_invalid;
20079 }
20080
20081
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.magic,f))
20082 {
20083 return qe_invalid;
20084 }
20085 }
20086
20087
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
20088 {
20089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
20090 {
20091 12 temp_zinit.max_magic*=32;
20092 12 temp_zinit.magic*=32;
20093 12 }
20094
20095
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20096 {
20097
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
20098 {
20099 return qe_invalid;
20100 }
20101 48 }
20102
20103
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
20104 {
20105 return qe_invalid;
20106 }
20107 12 }
20108 else
20109 {
20110
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.bomb_ratio,f))
20111 {
20112 return qe_invalid;
20113 }
20114 }
20115
20116
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
20117 {
20118 byte tempbp;
20119
20120
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20121 {
20122
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20123 {
20124 return qe_invalid;
20125 }
20126
20127 48 beam_power[i]=tempbp;
20128 48 }
20129
20130
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
20131 {
20132 return qe_invalid;
20133 }
20134
20135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
20136 {
20137 if(!p_getc(&hookshot_length,f))
20138 {
20139 return qe_invalid;
20140 }
20141
20142 if(!p_getc(&longshot_links,f))
20143 {
20144 return qe_invalid;
20145 }
20146
20147 if(!p_getc(&longshot_length,f))
20148 {
20149 return qe_invalid;
20150 }
20151 }
20152 12 }
20153
20154
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_x,f))
20155 {
20156 return qe_invalid;
20157 }
20158
20159
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_y,f))
20160 {
20161 return qe_invalid;
20162 }
20163
20164
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.subscreen,f))
20165 {
20166 return qe_invalid;
20167 }
20168
20169 //old only
20170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20171 {
20172 for(int32_t i=0; i<32; i++)
20173 {
20174 if(!p_getc(&temp_zinit.boss_key[i],f))
20175 {
20176 return qe_invalid;
20177 }
20178 }
20179 }
20180
20181
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20182 {
20183
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version <= 10)
20184 {
20185 byte tempbyte;
20186
20187
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
20188 {
20189 return qe_invalid;
20190 }
20191
20192 12 temp_zinit.start_dmap = (word)tempbyte;
20193 12 }
20194 else
20195 {
20196
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_dmap,f))
20197 {
20198 return qe_invalid;
20199 }
20200 }
20201
20202
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20203 {
20204 return qe_invalid;
20205 }
20206 125 }
20207
20208
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
125 if(s_version>1 && s_version < 29)
20209 {
20210
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20211 return qe_invalid;
20212 77 temp_zinit.arrows = padding;
20213
20214
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20215 return qe_invalid;
20216 77 temp_zinit.max_arrows = padding;
20217 77 }
20218
20219
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version>2)
20220 {
20221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version <= 10)
20222 {
20223 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20224 {
20225 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20226 {
20227 return qe_invalid;
20228 }
20229 }
20230 }
20231 else
20232 {
20233
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXLEVELS; i++)
20234 {
20235
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20236 {
20237 return qe_invalid;
20238 }
20239 57856 }
20240 }
20241 113 }
20242
20243
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>3)
20244 {
20245
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20246 {
20247 return qe_invalid;
20248 }
20249
20250
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20251 {
20252 return qe_invalid;
20253 }
20254
20255
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20256 {
20257 return qe_invalid;
20258 }
20259
20260
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20261 {
20262 return qe_invalid;
20263 }
20264
20265
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20266 {
20267 return qe_invalid;
20268 }
20269
20270
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20271 {
20272 return qe_invalid;
20273 }
20274
20275
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20276 {
20277 return qe_invalid;
20278 }
20279
20280
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_flags,f))
20281 {
20282 return qe_invalid;
20283 }
20284
20285
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20286
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20287 113 }
20288
20289
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>4 && s_version<15)
20290 {
20291 if(!p_getc(&moving_fairy_hearts,f))
20292 {
20293 return qe_invalid;
20294 }
20295
20296 if(!p_getc(&moving_fairy_heart_percent,f))
20297 {
20298 return qe_invalid;
20299 }
20300 }
20301
20302
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>5 && s_version < 10)
20303 {
20304 if(!p_getc(&temp,f))
20305 {
20306 return qe_invalid;
20307 }
20308
20309 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20310 }
20311
20312
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>6 && s_version<15)
20313 {
20314 if(!p_getc(&stationary_fairy_hearts,f))
20315 {
20316 return qe_invalid;
20317 }
20318
20319 if(!p_getc(&stationary_fairy_heart_percent,f))
20320 {
20321 return qe_invalid;
20322 }
20323
20324 if(!p_getc(&moving_fairy_magic,f))
20325 {
20326 return qe_invalid;
20327 }
20328
20329 if(!p_getc(&moving_fairy_magic_percent,f))
20330 {
20331 return qe_invalid;
20332 }
20333
20334 if(!p_getc(&stationary_fairy_magic,f))
20335 {
20336 return qe_invalid;
20337 }
20338
20339 if(!p_getc(&stationary_fairy_magic_percent,f))
20340 {
20341 return qe_invalid;
20342 }
20343
20344 if(!p_getc(&blue_potion_hearts,f))
20345 {
20346 return qe_invalid;
20347 }
20348
20349 if(!p_getc(&blue_potion_heart_percent,f))
20350 {
20351 return qe_invalid;
20352 }
20353
20354 if(!p_getc(&red_potion_hearts,f))
20355 {
20356 return qe_invalid;
20357 }
20358
20359 if(!p_getc(&red_potion_heart_percent,f))
20360 {
20361 return qe_invalid;
20362 }
20363
20364 if(!p_getc(&blue_potion_magic,f))
20365 {
20366 return qe_invalid;
20367 }
20368
20369 if(!p_getc(&blue_potion_magic_percent,f))
20370 {
20371 return qe_invalid;
20372 }
20373
20374 if(!p_getc(&red_potion_magic,f))
20375 {
20376 return qe_invalid;
20377 }
20378
20379 if(!p_getc(&red_potion_magic_percent,f))
20380 {
20381 return qe_invalid;
20382 }
20383 }
20384
20385
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>6)
20386 {
20387
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.subscreen_style,f))
20388 {
20389 return qe_invalid;
20390 }
20391 113 }
20392
20393
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>7)
20394 {
20395
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.usecustomsfx,f))
20396 {
20397 return qe_invalid;
20398 }
20399 113 }
20400
20401
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>8)
20402 {
20403
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_rupees,f))
20404 {
20405 return qe_invalid;
20406 }
20407
20408
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_keys,f))
20409 {
20410 return qe_invalid;
20411 }
20412 113 }
20413
20414
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>16)
20415 {
20416
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.gravity,f))
20417 {
20418 return qe_invalid;
20419 }
20420
20421
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.terminalv,f))
20422 {
20423 return qe_invalid;
20424 }
20425
20426
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_speed,f))
20427 {
20428 return qe_invalid;
20429 }
20430
20431
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.transition_type,f))
20432 {
20433 return qe_invalid;
20434 }
20435
20436
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20437 {
20438 return qe_invalid;
20439 }
20440 113 }
20441
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20442 12 temp_zinit.msg_speed = 0;
20443
20444
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>17)
20445 {
20446
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20447 {
20448 return qe_invalid;
20449 }
20450 113 }
20451
20452 //expaned init data for larger values in 2.55
20453
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20454 {
20455
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.bombs,f))
20456 {
20457 return qe_invalid;
20458 }
20459
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.super_bombs,f))
20460 {
20461 return qe_invalid;
20462 }
20463
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_bombs,f))
20464 {
20465 return qe_invalid;
20466 }
20467
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_sbombs,f))
20468 {
20469 return qe_invalid;
20470 }
20471
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.arrows,f))
20472 {
20473 return qe_invalid;
20474 }
20475
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_arrows,f))
20476 {
20477 return qe_invalid;
20478 }
20479
20480 36 }
20481
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 20 )
20482 {
20483
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroStep,f))
20484 {
20485 return qe_invalid;
20486 }
20487 36 }
20488 else
20489 {
20490 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20491 }
20492
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 21 )
20493 {
20494
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20495 {
20496 return qe_invalid;
20497 }
20498 36 }
20499 else
20500 {
20501 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20502 }
20503 //old only
20504
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20505 {
20506 byte items2;
20507
20508 if(!p_getc(&items2,f))
20509 {
20510 return qe_invalid;
20511 }
20512
20513 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20514 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20515 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20516 }
20517
20518
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
20519 {
20520 for(int32_t q=0; q<96; q++)
20521 {
20522 if(!p_getc(&padding,f))
20523 {
20524 return qe_invalid;
20525 }
20526 }
20527
20528 //new only
20529 if((Header->zelda_version == 0x192)&&(Header->build>173))
20530 {
20531 if(!p_getc(&padding,f))
20532 {
20533 return qe_invalid;
20534 }
20535
20536 if(!p_getc(&padding,f))
20537 {
20538 return qe_invalid;
20539 }
20540 }
20541 }
20542 125 }
20543
20544
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20545 {
20546 //temp_zinit.shield=i_smallshield;
20547
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 31 times.
47 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20548
20549
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20550 16 temp_zinit.items[sshieldid] = true;
20551 16 }
20552
20553
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20554 {
20555 4 temp_zinit.hc=3;
20556 4 temp_zinit.start_heart=3;
20557 4 temp_zinit.cont_heart=3;
20558 4 temp_zinit.max_bombs=8;
20559 4 }
20560
20561
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20562 {
20563 4 sword_hearts[0]=0;
20564 4 sword_hearts[1]=5;
20565 4 sword_hearts[2]=12;
20566 4 sword_hearts[3]=21;
20567 4 }
20568
20569
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20570 {
20571 4 temp_zinit.last_map=0;
20572 4 temp_zinit.last_screen=0;
20573 4 }
20574
20575
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20576 {
20577 4 temp_zinit.max_magic=0;
20578 4 temp_zinit.magic=0;
20579
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20580 4 }
20581
20582
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20583 {
20584
20585
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20586 {
20587 16 beam_hearts[x]=100;
20588 16 }
20589
20590
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20591 {
20592
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20593
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20594 16 }
20595
20596
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20597 {
20598
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20599 16 }
20600
20601
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20602 4 hookshot_links=100;
20603 4 temp_zinit.msg_more_x=224;
20604 4 temp_zinit.msg_more_y=64;
20605 4 }
20606
20607 // Okay, let's put these legacy values into itemsbuf.
20608
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 15)
20609
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20610 {
20611
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20612 {
20613 case iFairyStill:
20614 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20615 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20616 16 itemsbuf[i].misc3 = 0;
20617 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20618 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20619 16 break;
20620
20621 case iFairyMoving:
20622 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20623 16 itemsbuf[i].misc2 = moving_fairy_magic;
20624 16 itemsbuf[i].misc3 = 50;
20625 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20626 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20627 16 break;
20628
20629 case iRPotion:
20630 16 itemsbuf[i].misc1 = red_potion_hearts;
20631 16 itemsbuf[i].misc2 = red_potion_magic;
20632 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20633 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20634 16 break;
20635
20636 case iBPotion:
20637 16 itemsbuf[i].misc1 = blue_potion_hearts;
20638 16 itemsbuf[i].misc2 = blue_potion_magic;
20639 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20640 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20641 16 break;
20642
20643 case iSword:
20644 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20645 16 itemsbuf[i].misc1 = beam_hearts[0];
20646 16 itemsbuf[i].misc2 = beam_power[0];
20647 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20648
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20649 16 break;
20650
20651 case iWSword:
20652 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20653 16 itemsbuf[i].misc1 = beam_hearts[1];
20654 16 itemsbuf[i].misc2 = beam_power[1];
20655
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20656 16 break;
20657
20658 case iMSword:
20659 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20660 16 itemsbuf[i].misc1 = beam_hearts[2];
20661 16 itemsbuf[i].misc2 = beam_power[2];
20662
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20663 16 break;
20664
20665 case iXSword:
20666 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20667 16 itemsbuf[i].misc1 = beam_hearts[3];
20668 16 itemsbuf[i].misc2 = beam_power[3];
20669
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20670 16 break;
20671
20672 case iHookshot:
20673 16 itemsbuf[i].misc1 = hookshot_length;
20674 16 itemsbuf[i].misc2 = hookshot_links;
20675 16 break;
20676
20677 case iLongshot:
20678 16 itemsbuf[i].misc1 = longshot_length;
20679 16 itemsbuf[i].misc2 = longshot_links;
20680 16 break;
20681 }
20682 4112 }
20683
20684
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20685 {
20686 //was new subscreen rule
20687
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20688
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20689 4 }
20690
20691
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20692 {
20693 4 temp_zinit.start_dmap=0;
20694 4 }
20695
20696
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20697 {
20698
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20699 4 }
20700
20701
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
129 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20702 {
20703 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20704 temp_zinit.max_rupees=999;
20705 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20706 }
20707
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20708 {
20709 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20710 temp_zinit.max_bombs = 8;
20711 }
20712 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20713 //time to ensure that we port all new values properly:
20714
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version < 0x250)
20715 {
20716
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20717 16 }
20718
20719
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 21)
20720 {
20721
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hp_per_heart,f))
20722 {
20723 return qe_invalid;
20724 }
20725
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magic_per_block,f))
20726 {
20727 return qe_invalid;
20728 }
20729
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20730 {
20731 return qe_invalid;
20732 }
20733
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20734 {
20735 return qe_invalid;
20736 }
20737 36 }
20738 else
20739 {
20740 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20741 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20742 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20743 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20744 }
20745
20746
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 22)
20747 {
20748
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20749 {
20750
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20751 {
20752 return qe_invalid;
20753 }
20754 900 }
20755
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20756 {
20757
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20758 {
20759 return qe_invalid;
20760 }
20761 900 }
20762 36 }
20763 else
20764 {
20765
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20766 {
20767 2325 temp_zinit.scrcnt[q] = 0;
20768 2325 temp_zinit.scrmaxcnt[q] = 0;
20769 2325 }
20770 }
20771
20772
20773
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 23)
20774 {
20775
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_type,f))
20776 {
20777 return qe_invalid;
20778 }
20779
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_arg,f))
20780 {
20781 return qe_invalid;
20782 }
20783
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_percent,f))
20784 {
20785 return qe_invalid;
20786 }
20787
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.def_lightrad,f))
20788 {
20789 return qe_invalid;
20790 }
20791
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.transdark_percent,f))
20792 {
20793 return qe_invalid;
20794 }
20795 36 }
20796 else
20797 {
20798 93 temp_zinit.dither_type = 0;
20799 93 temp_zinit.dither_arg = 0;
20800 93 temp_zinit.dither_percent = 20;
20801 93 temp_zinit.def_lightrad = 24;
20802 93 temp_zinit.transdark_percent = 0;
20803 }
20804
20805
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 24)
20806 {
20807
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.darkcol,f))
20808 {
20809 return qe_invalid;
20810 }
20811 36 }
20812 else
20813 {
20814 93 temp_zinit.darkcol = BLACK;
20815 }
20816
20817
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 25)
20818 {
20819
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.gravity2,f))
20820 {
20821 return qe_invalid;
20822 }
20823
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.swimgravity,f))
20824 {
20825 return qe_invalid;
20826 }
20827 36 }
20828 else
20829 {
20830 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20831 93 temp_zinit.swimgravity = 5;
20832 }
20833
20834
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 26)
20835 {
20836
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20837 {
20838 return qe_invalid;
20839 }
20840
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20841 {
20842 return qe_invalid;
20843 }
20844
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20845 {
20846 return qe_invalid;
20847 }
20848 36 }
20849 else
20850 {
20851 93 temp_zinit.heroSideswimUpStep = 150;
20852 93 temp_zinit.heroSideswimSideStep = 100;
20853 93 temp_zinit.heroSideswimDownStep = 75;
20854 }
20855
20856
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 27)
20857 {
20858
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20859 {
20860 return qe_invalid;
20861 }
20862 36 }
20863 else
20864 {
20865 93 temp_zinit.exitWaterJump = 0;
20866 }
20867
20868
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 29)
20869 {
20870
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20871 {
20872 return qe_invalid;
20873 }
20874 36 }
20875 else
20876 {
20877 93 temp_zinit.bunny_ltm = 0;
20878 }
20879
20880
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 30)
20881 {
20882
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.switchhookstyle,f))
20883 {
20884 return qe_invalid;
20885 }
20886 36 }
20887 else
20888 {
20889 93 temp_zinit.switchhookstyle = 1;
20890 }
20891
20892
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 31)
20893 {
20894
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magicdrainrate,f))
20895 {
20896 return qe_invalid;
20897 }
20898 36 }
20899 else
20900 {
20901
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20902
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20903 }
20904
20905
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 temp_zinit.clear_genscript();
20906
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(s_version > 32)
20907 {
20908 34 word numgenscript = 0;
20909
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&numgenscript,f))
20910 return qe_invalid;
20911
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20912 return qe_invalid;
20913
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 for(auto q = 1; q < numgenscript; ++q)
20914 {
20915 if(!p_getc(&padding,f))
20916 return qe_invalid;
20917 if(!(padding&2))
20918 continue;
20919 temp_zinit.gen_doscript[q] = padding&1;
20920 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20921 return qe_invalid;
20922 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20923 return qe_invalid;
20924 for(auto p = 0; p < 8; ++p)
20925 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20926 return qe_invalid;
20927 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20928 return qe_invalid;
20929 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20930 return qe_invalid;
20931 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20932 return qe_invalid;
20933 }
20934 34 }
20935
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(s_version > 33)
20936 {
20937
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20938 return qe_invalid;
20939
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if(!p_getc(&temp_zinit.hero_swim_div,f))
20940 return qe_invalid;
20941 31 }
20942
20943
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 zinit = temp_zinit;
20944
20945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(zinit.heroAnimationStyle==las_zelda3slow)
20946 {
20947 hero_animation_speed=2;
20948 }
20949 else
20950 {
20951 129 hero_animation_speed=1;
20952 }
20953
20954 129 return 0;
20955 441 }
20956
20957 /*
20958 void setupitemdropsets()
20959 {
20960 for(int32_t i=0; i<isMAX; i++)
20961 {
20962 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20963 }
20964 }
20965 */
20966
20967 117 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20968 {
20969 117 build=build; // here to prevent compiler warnings
20970 dword dummy_dword;
20971 117 word item_drop_sets_to_read=0;
20972 item_drop_object tempitemdrop;
20973 117 word s_version=0, s_cversion=0;
20974
20975
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 117 times.
30069 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20976 {
20977 29952 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20978 29952 }
20979
20980
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
117 if(version > 0x192)
20981 {
20982 113 item_drop_sets_to_read=0;
20983
20984 //section version info
20985
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_version,f))
20986 {
20987 return qe_invalid;
20988 }
20989
20990 113 FFCore.quest_format[vItemDropsets] = s_version;
20991
20992 //al_trace("Item drop sets version %d\n", s_version);
20993
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
20994 {
20995 return qe_invalid;
20996 }
20997
20998 //section size
20999
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
21000 {
21001 return qe_invalid;
21002 }
21003
21004 //finally... section data
21005
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&item_drop_sets_to_read,f))
21006 {
21007 return qe_invalid;
21008 }
21009
21010
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
21011 {
21012 return qe_invalid;
21013 }
21014 113 }
21015 else
21016 {
21017 4 init_item_drop_sets();
21018 }
21019
21020
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 113 times.
117 if(s_version>=1)
21021 {
21022
2/2
✓ Branch 0 taken 2069 times.
✓ Branch 1 taken 113 times.
2182 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21023 {
21024
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
21025 {
21026 return qe_invalid;
21027 }
21028
21029
2/2
✓ Branch 0 taken 20690 times.
✓ Branch 1 taken 2069 times.
22759 for(int32_t j=0; j<10; ++j)
21030 {
21031
1/2
✓ Branch 0 taken 20690 times.
✗ Branch 1 not taken.
20690 if(!p_igetw(&tempitemdrop.item[j],f))
21032 {
21033 return qe_invalid;
21034 }
21035 20690 }
21036
21037
2/2
✓ Branch 0 taken 22759 times.
✓ Branch 1 taken 2069 times.
24828 for(int32_t j=0; j<11; ++j)
21038 {
21039
1/2
✓ Branch 0 taken 22759 times.
✗ Branch 1 not taken.
22759 if(!p_igetw(&tempitemdrop.chance[j],f))
21040 {
21041 return qe_invalid;
21042 }
21043 22759 }
21044
21045 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21046 // overrides the quest's set #12.
21047
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2069 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2069 if(s_version<2 && i==12)
21048 continue;
21049
21050 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21051
1/4
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2069 if(s_version<2) for(int32_t j=0; j<10; ++j)
21052 {
21053 int32_t it = tempitemdrop.item[j];
21054
21055 if((itemsbuf[it].family == itype_rupee
21056 && ((itemsbuf[it].amount)&0xFFF) == 10)
21057 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21058 {
21059 tempitemdrop.chance[j+1]=0;
21060 }
21061 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21062 {
21063 tempitemdrop.chance[j+1]=0;
21064 }
21065
21066 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21067 if(itemsbuf[it].family == itype_misc)
21068 {
21069 // If a non-gameplay item was selected, then item drop was aborted.
21070 // Reflect this by increasing the 'Nothing' chance accordingly.
21071 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21072 tempitemdrop.chance[j+1]=0;
21073 }
21074 }
21075
21076 2069 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21077 2069 }
21078 113 }
21079
21080 117 return 0;
21081 117 }
21082
21083 113 int32_t readfavorites(PACKFILE *f, int32_t, word)
21084 {
21085 int32_t temp_num;
21086 dword dummy_dword;
21087 word num_favorite_combos;
21088 word num_favorite_combo_aliases;
21089 113 word s_version=0, s_cversion=0;
21090
21091 //section version info
21092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
21093 {
21094 return qe_invalid;
21095 }
21096
21097 113 FFCore.quest_format[vFavourites] = s_version;
21098
21099
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
21100 {
21101 return qe_invalid;
21102 }
21103
21104 //section size
21105
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
21106 {
21107 return qe_invalid;
21108 }
21109
21110 113 word per_row = FAVORITECOMBO_PER_ROW;
21111
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 if(s_version >= 3)
21112
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&per_row,f))
21113 return qe_invalid;
21114 //finally... section data
21115
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combos,f))
21116 {
21117 return qe_invalid;
21118 }
21119
21120 //Hack; port old favorite combos
21121
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
113 if(s_version < 3 && num_favorite_combos == 100)
21122 82 per_row = 13;
21123
21124
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21125 33900 favorite_combos[q] = -1;
21126
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21127 33900 favorite_comboaliases[q] = -1;
21128
2/2
✓ Branch 0 taken 8735 times.
✓ Branch 1 taken 113 times.
8848 for(int32_t i=0; i<num_favorite_combos; i++)
21129 {
21130
1/2
✓ Branch 0 taken 8735 times.
✗ Branch 1 not taken.
8735 if(!p_igetl(&temp_num,f))
21131 {
21132 return qe_invalid;
21133 }
21134
21135
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 8200 times.
8735 if(per_row == FAVORITECOMBO_PER_ROW)
21136 535 favorite_combos[i]=temp_num;
21137 else
21138 {
21139 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21140 8200 favorite_combos[new_i]=temp_num;
21141 }
21142 8735 }
21143
21144
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combo_aliases,f))
21145 {
21146 return qe_invalid;
21147 }
21148
21149
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 113 times.
8313 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21150 {
21151
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if(!p_igetl(&temp_num,f))
21152 {
21153 return qe_invalid;
21154 }
21155
21156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8200 times.
8200 if(per_row == FAVORITECOMBO_PER_ROW)
21157 favorite_comboaliases[i]=temp_num;
21158 else
21159 {
21160 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21161 8200 favorite_comboaliases[new_i]=temp_num;
21162 }
21163 8200 }
21164
21165 113 word max_combo_cols = 0;
21166 113 word max_mappages = 0;
21167
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 if(s_version >= 2)
21168 {
21169
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&max_combo_cols,f))
21170 return qe_invalid;
21171 31 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21172
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
155 for(int q = 0; q < max_combo_cols; ++q)
21173 {
21174
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp,f))
21175 return qe_invalid;
21176
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp2,f))
21177 return qe_invalid;
21178
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp3,f))
21179 return qe_invalid;
21180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(q < MAX_COMBO_COLS)
21181 {
21182 124 First[q] = tmp;
21183 124 combo_alistpos[q] = tmp2;
21184 124 combo_pool_listpos[q] = tmp3;
21185 124 }
21186 124 }
21187
21188
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&max_mappages,f))
21189 return qe_invalid;
21190
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 31 times.
310 for(int q = 0; q < max_mappages; ++q)
21191 {
21192
1/2
✓ Branch 0 taken 279 times.
✗ Branch 1 not taken.
279 if(!p_igetl(&tmp,f))
21193 return qe_invalid;
21194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(!p_igetl(&tmp2,f))
21195 return qe_invalid;
21196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(q < MAX_MAPPAGE_BTNS)
21197 {
21198 279 map_page[q].map = tmp;
21199 279 map_page[q].screen = tmp2;
21200 279 }
21201 279 }
21202 31 }
21203
21204
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 113 times.
441 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21205 {
21206 328 First[q] = 0;
21207 328 combo_alistpos[q] = 0;
21208 328 combo_pool_listpos[q] = 0;
21209 328 }
21210
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 113 times.
851 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21211 {
21212 738 map_page[q].map = 0;
21213 738 map_page[q].screen = 0;
21214 738 }
21215
21216 113 return 0;
21217 113 }
21218
21219 /*
21220 switch (ret) {
21221 case 0:
21222 break;
21223
21224 case qe_invalid:
21225 goto invalid;
21226 break;
21227 default:
21228 pack_fclose(f);
21229 if(!oldquest)
21230 delete_file(tmpfilename);
21231 return ret;
21232 break;
21233 }
21234 */
21235
21236 const char *skip_text[skip_max]=
21237 {
21238 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21239 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21240 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21241 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21242 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21243 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21244 "skip_favorites"
21245 };
21246
21247
21248 void port250QuestRules(){
21249
21250 portCandleRules(); //Candle
21251 portBombRules();
21252
21253 }
21254
21255 void portCandleRules()
21256 {
21257 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21258 //itemdata itemsbuf;
21259 for ( int32_t q = 0; q < MAXITEMS; q++ )
21260 {
21261 if ( itemsbuf[q].family == itype_candle )
21262 {
21263 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21264 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21265 }
21266 }
21267 }
21268
21269 void portBombRules()
21270 {
21271 bool hurtshero = get_qr(qr_OUCHBOMBS);
21272 //itemdata itemsbuf;
21273 for ( int32_t q = 0; q < MAXITEMS; q++ )
21274 {
21275 if ( itemsbuf[q].family == itype_bomb )
21276 {
21277 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21278 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21279 }
21280 }
21281 }
21282
21283 2892 static int section_id_to_enum(int id)
21284 {
21285
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 125 times.
✓ Branch 6 taken 113 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 125 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 113 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 125 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 113 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 125 times.
✓ Branch 23 taken 113 times.
✓ Branch 24 taken 113 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2892 switch (id)
21286 {
21287 case ID_HEADER: return skip_header;
21288 125 case ID_RULES: return skip_rules;
21289 125 case ID_STRINGS: return skip_strings;
21290 125 case ID_MISC: return skip_misc;
21291 125 case ID_TILES: return skip_tiles;
21292 125 case ID_COMBOS: return skip_combos;
21293 113 case ID_COMBOALIASES: return skip_comboaliases;
21294 125 case ID_CSETS: return skip_csets;
21295 125 case ID_MAPS: return skip_maps;
21296 125 case ID_DMAPS: return skip_dmaps;
21297 125 case ID_DOORS: return skip_doors;
21298 125 case ID_ITEMS: return skip_items;
21299 125 case ID_WEAPONS: return skip_weapons;
21300 113 case ID_COLORS: return skip_colors;
21301 113 case ID_ICONS: return skip_icons;
21302 125 case ID_INITDATA: return skip_initdata;
21303 125 case ID_GUYS: return skip_guys;
21304 113 case ID_HEROSPRITES: return skip_herosprites;
21305 113 case ID_SUBSCREEN: return skip_subscreens;
21306 113 case ID_FFSCRIPT: return skip_ffscript;
21307 113 case ID_SFX: return skip_sfx;
21308 125 case ID_MIDIS: return skip_midis;
21309 125 case ID_CHEATS: return skip_cheats;
21310 113 case ID_ITEMDROPSETS: return skip_itemdropsets;
21311 113 case ID_FAVORITES: return skip_favorites;
21312 case ID_ZINFO: return skip_zinfo;
21313 }
21314
21315 return -1;
21316 2892 }
21317
21318 2892 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21319 {
21320 2892 int section_enum = section_id_to_enum(section_id);
21321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 if (skip)
21323 {
21324 word s_version;
21325 if (!p_igetw(&s_version,f))
21326 {
21327 return qe_invalid;
21328 }
21329
21330 word c_version;
21331 if (!p_igetw(&c_version,f))
21332 {
21333 return qe_invalid;
21334 }
21335
21336 if (section_id == ID_RULES && s_version > 16)
21337 {
21338 dword dummy;
21339 if (!p_igetl(&dummy,f))
21340 {
21341 return qe_invalid;
21342 }
21343 }
21344
21345 if (section_id == ID_FFSCRIPT && s_version >= 18)
21346 {
21347 word dummy;
21348 if (!p_igetw(&dummy,f))
21349 {
21350 return qe_invalid;
21351 }
21352 }
21353
21354 dword section_length;
21355 if (!p_igetl(&section_length,f))
21356 {
21357 return qe_invalid;
21358 }
21359
21360 if (pack_fseek(f, section_length))
21361 {
21362 return qe_invalid;
21363 }
21364
21365 if (!pack_feof(f))
21366 {
21367 if (!p_mgetl(&section_id,f))
21368 {
21369 return qe_invalid;
21370 }
21371 }
21372
21373 return qe_cancel;
21374 }
21375
21376 2892 return qe_OK;
21377 2892 }
21378
21379 //Internal function for loadquest wrapper
21380 129 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, const byte *skip_flags, byte printmetadata)
21381 {
21382 129 DMapEditorLastMaptileUsed = 0;
21383 129 combosread=false;
21384 129 mapsread=false;
21385 129 fixffcs=false;
21386
21387 // show_progress=true;
21388 char tmpfilename[L_tmpnam];
21389 129 temp_name(tmpfilename);
21390 // char percent_done[30];
21391 129 bool catchup=false;
21392 byte tempbyte;
21393 129 word old_map_count=map_count;
21394
21395 129 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21396 129 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21397 129 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21398
21399
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
21400 {
21401 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21402 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21403 }
21404
21405 129 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21406 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21407
21408
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
21409 {
21410 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21411 }
21412
21413
21414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_ffscript))
21415 {
21416 129 zScript.clear();
21417 129 globalmap.clear();
21418 129 genericmap.clear();
21419 129 ffcmap.clear();
21420 129 itemmap.clear();
21421 129 npcmap.clear();
21422 129 ewpnmap.clear();
21423 129 lwpnmap.clear();
21424 129 playermap.clear();
21425 129 dmapmap.clear();
21426 129 screenmap.clear();
21427 129 itemspritemap.clear();
21428 129 comboscriptmap.clear();
21429
21430
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21431 {
21432 65919 ffcmap[i].clear();
21433 65919 }
21434
21435 129 globalmap[0].slotname = "Slot 1:";
21436 129 globalmap[0].scriptname = "~Init";
21437 129 globalmap[0].update();
21438
21439
2/2
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 129 times.
1032 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21440 {
21441 903 globalmap[i].clear();
21442 903 }
21443
21444
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21445 {
21446 32895 itemmap[i].clear();
21447 32895 }
21448
21449 //new script types -- prevent carrying over to a quest that you load after reading them
21450 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21451
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21452 {
21453 32895 npcmap[i].clear();
21454 32895 }
21455
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21456 {
21457 32895 lwpnmap[i].clear();
21458 32895 }
21459
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21460 {
21461 32895 ewpnmap[i].clear();
21462 32895 }
21463
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 129 times.
645 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21464 {
21465 516 playermap[i].clear();
21466 516 }
21467
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21468 {
21469 32895 dmapmap[i].clear();
21470 32895 }
21471
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21472 {
21473 32895 screenmap[i].clear();
21474 32895 }
21475
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21476 {
21477 32895 itemspritemap[i].clear();
21478 32895 }
21479
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21480 {
21481 65919 comboscriptmap[i].clear();
21482 65919 }
21483
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21484 {
21485 65919 genericmap[i].clear();
21486 65919 }
21487
21488 129 reset_scripts();
21489 129 }
21490
21491 zquestheader tempheader;
21492 129 memset(&tempheader, 0, sizeof(zquestheader));
21493 129 zinfo tempzi;
21494 129 tempzi.clear();
21495 129 load_tmp_zi = &tempzi;
21496
21497 // oldquest flag is set when an unencrypted qst file is suspected.
21498 129 bool oldquest = false;
21499 129 int32_t open_error=0;
21500 129 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21501
21502
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!f)
21503 {
21504 ASSERT(open_error != 0);
21505 return open_error;
21506 }
21507 char zinfofilename[2048];
21508 129 replace_extension(zinfofilename, filename, "zinfo", 2047);
21509 129 int32_t ret=0;
21510
21511 //header
21512 129 box_out("Reading Header...");
21513 129 ret=readheader(f, &tempheader, printmetadata);
21514
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
129 checkstatus(ret);
21515 129 box_out("okay.");
21516 129 box_eol();
21517
21518
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(read_zinfo)
21519 {
21520 36 box_out("Reading ZInfo - ");
21521
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 box_out(read_ext_zinfo ? "External..." : "Internal...");
21522
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 if(read_ext_zinfo)
21523 {
21524 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21525 1 ret=readzinfo(inf, tempzi, tempheader);
21526
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21527
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21528 1 }
21529 else
21530 {
21531 35 ret=readzinfo(f, tempzi, tempheader);
21532
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
35 checkstatus(ret);
21533 }
21534 36 box_out("okay.");
21535 36 box_eol();
21536 36 }
21537
21538
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version>=0x193)
21539 {
21540 dword section_id;
21541
21542 //section id
21543
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_mgetl(&section_id,f))
21544 {
21545 return qe_invalid;
21546 }
21547
21548 125 std::set<dword> seen_sections;
21549
21550
3/4
✓ Branch 0 taken 3017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✓ Branch 3 taken 125 times.
3017 while(!pack_feof(f))
21551 {
21552
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (seen_sections.contains(section_id))
21553 return qe_invalid;
21554
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 seen_sections.insert(section_id);
21555
21556
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21557 {
21558 if (retval == qe_cancel)
21559 continue;
21560 checkstatus(retval);
21561 }
21562
21563
24/25
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 113 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 125 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 113 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 125 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 113 times.
✓ Branch 23 taken 113 times.
✗ Branch 24 not taken.
2892 switch(section_id)
21564 {
21565 case ID_RULES:
21566
21567 //rules
21568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21569 {
21570 box_out("found.");
21571 box_eol();
21572 catchup=false;
21573 }
21574
21575
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Rules...");
21576
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readrules(f, &tempheader);
21577
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21578
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21579
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21580 125 break;
21581
21582 case ID_STRINGS:
21583
21584 //strings
21585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21586 {
21587 box_out("found.");
21588 box_eol();
21589 catchup=false;
21590 }
21591
21592
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Strings...");
21593
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readstrings(f, &tempheader);
21594
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21595
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21596
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21597 125 break;
21598
21599 case ID_MISC:
21600
21601 //misc data
21602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21603 {
21604 box_out("found.");
21605 box_eol();
21606 catchup=false;
21607 }
21608
21609
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Misc. Data...");
21610
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmisc(f, &tempheader, Misc);
21611
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21612
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21613
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21614 125 break;
21615
21616 case ID_TILES:
21617
21618 //tiles
21619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21620 {
21621 box_out("found.");
21622 box_eol();
21623 catchup=false;
21624 }
21625
21626
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tiles...");
21627
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21628
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21629
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21630
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21631 125 break;
21632
21633 case ID_COMBOS:
21634
21635 //combos
21636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21637 {
21638 box_out("found.");
21639 box_eol();
21640 catchup=false;
21641 }
21642
21643
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Combos...");
21644
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21645 125 combosread=true;
21646
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21647
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21648
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21649 125 break;
21650
21651 case ID_COMBOALIASES:
21652
21653 //combo aliases
21654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21655 {
21656 box_out("found.");
21657 box_eol();
21658 catchup=false;
21659 }
21660
21661
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Combo Aliases...");
21662
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21663
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21664
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21665
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21666 113 break;
21667
21668 case ID_CSETS:
21669
21670 //color data
21671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21672 {
21673 box_out("found.");
21674 box_eol();
21675 catchup=false;
21676 }
21677
21678
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Color Data...");
21679
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21680
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21681
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21682
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21683 125 break;
21684
21685 case ID_MAPS:
21686
21687 //maps
21688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21689 {
21690 box_out("found.");
21691 box_eol();
21692 catchup=false;
21693 }
21694
21695
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Maps...");
21696
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmaps(f, &tempheader);
21697 125 mapsread=true;
21698
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21699
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21700
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21701 125 break;
21702
21703 case ID_DMAPS:
21704
21705 //dmaps
21706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21707 {
21708 box_out("found.");
21709 box_eol();
21710 catchup=false;
21711 }
21712
21713
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading DMaps...");
21714
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21715
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21716
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21717
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21718 125 break;
21719
21720 case ID_DOORS:
21721
21722 //door combo sets
21723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21724 {
21725 box_out("found.");
21726 box_eol();
21727 catchup=false;
21728 }
21729
21730
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Doors...");
21731
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdoorcombosets(f, &tempheader);
21732
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21733
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21734
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21735 125 break;
21736
21737 case ID_ITEMS:
21738
21739 //items
21740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21741 {
21742 box_out("found.");
21743 box_eol();
21744 catchup=false;
21745 }
21746
21747
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Items...");
21748
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21749
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21750
21751
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21752
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21753 125 break;
21754
21755 case ID_WEAPONS:
21756
21757 //weapons
21758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21759 {
21760 box_out("found.");
21761 box_eol();
21762 catchup=false;
21763 }
21764
21765
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Weapons...");
21766
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readweapons(f, &tempheader);
21767
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21768
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21769
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21770 125 break;
21771
21772 case ID_COLORS:
21773
21774 //misc. colors
21775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21776 {
21777 box_out("found.");
21778 box_eol();
21779 catchup=false;
21780 }
21781
21782
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Misc. Colors...");
21783
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readmisccolors(f, &tempheader, Misc);
21784
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21785
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21786
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21787 113 break;
21788
21789 case ID_ICONS:
21790
21791 //game icons
21792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21793 {
21794 box_out("found.");
21795 box_eol();
21796 catchup=false;
21797 }
21798
21799
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Game Icons...");
21800
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readgameicons(f, &tempheader, Misc);
21801
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21802
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21803
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21804 113 break;
21805
21806 case ID_INITDATA:
21807
21808 //initialization data
21809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21810 {
21811 box_out("found.");
21812 box_eol();
21813 catchup=false;
21814 }
21815
21816
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Init. Data...");
21817
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readinitdata(f, &tempheader);
21818
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21819
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21820
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21821
21822
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_subscreens))
21823 {
21824
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 98 times.
125 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21825 {
21826
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21827
21828
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21829 {
21830 13824 int32_t type=DMaps[i].type&dmfTYPE;
21831
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21832
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21833 13824 }
21834 27 }
21835 125 }
21836
21837
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_sfx))
21838 {
21839 125 setupsfx();
21840 125 }
21841
21842
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!get_bit(skip_flags, skip_itemdropsets))
21843 {
21844
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_item_drop_sets();
21845 125 }
21846
21847
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_favorites))
21848 {
21849 125 init_favorites();
21850 125 }
21851
21852 125 break;
21853
21854 case ID_GUYS:
21855
21856 //guys
21857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21858 {
21859 box_out("found.");
21860 box_eol();
21861 catchup=false;
21862 }
21863
21864
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Custom Guy Data...");
21865
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readguys(f, &tempheader);
21866
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21867
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21868
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21869 125 break;
21870
21871 case ID_HEROSPRITES:
21872
21873 //player sprites
21874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21875 {
21876 box_out("found.");
21877 box_eol();
21878 catchup=false;
21879 }
21880
21881
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Player Sprite Data...");
21882
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readherosprites(f, &tempheader);
21883
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21884
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21885
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21886 113 break;
21887
21888 case ID_SUBSCREEN:
21889
21890 //custom subscreens
21891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21892 {
21893 box_out("found.");
21894 box_eol();
21895 catchup=false;
21896 }
21897
21898
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Subscreen Data...");
21899
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsubscreens(f, &tempheader);
21900
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21901
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21902
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21903 113 break;
21904
21905 case ID_FFSCRIPT:
21906
21907 //Freeform combo scripts
21908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21909 {
21910 box_out("found.");
21911 box_eol();
21912 catchup=false;
21913 }
21914
21915
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading FF Script Data...");
21916
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readffscript(f, &tempheader);
21917
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21918
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21919
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21920 113 break;
21921
21922 case ID_SFX:
21923
21924 //SFX data
21925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21926 {
21927 box_out("found.");
21928 box_eol();
21929 catchup=false;
21930 }
21931
21932
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading SFX Data...");
21933
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsfx(f, &tempheader);
21934
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21935
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21936
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21937 113 break;
21938
21939 case ID_MIDIS:
21940
21941 //midis
21942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21943 {
21944 box_out("found.");
21945 box_eol();
21946 catchup=false;
21947 }
21948
21949
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tunes...");
21950
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtunes(f, &tempheader, tunes);
21951
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21952
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21953
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21954 125 break;
21955
21956 case ID_CHEATS:
21957
21958 //cheat codes
21959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21960 {
21961 box_out("found.");
21962 box_eol();
21963 catchup=false;
21964 }
21965
21966
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Cheat Codes...");
21967
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcheatcodes(f, &tempheader);
21968
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21969
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21970
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21971 125 break;
21972
21973 case ID_ITEMDROPSETS:
21974
21975 //item drop sets
21976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21977 {
21978 box_out("found.");
21979 box_eol();
21980 catchup=false;
21981 }
21982
21983
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Item Drop Sets...");
21984
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21985
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21986
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21987
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21988 113 break;
21989
21990 case ID_FAVORITES:
21991
21992 //favorite combos and combo aliases
21993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21994 {
21995 box_out("found.");
21996 box_eol();
21997 catchup=false;
21998 }
21999
22000
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Favorite Combos...");
22001
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
22002
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
22003
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
22004
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
22005 113 break;
22006
22007 default:
22008 if(!catchup)
22009 {
22010 box_out("Bad token! Searching...");
22011 box_eol();
22012 }
22013
22014 catchup=true;
22015 break;
22016 }
22017
22018
22019
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 if(catchup)
22020 {
22021 //section id
22022 section_id=(section_id<<8);
22023
22024 if(!p_getc(&tempbyte,f))
22025 {
22026 return qe_invalid;
22027 }
22028
22029 section_id+=tempbyte;
22030 }
22031
22032 else
22033 {
22034 //section id
22035
3/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 125 times.
2892 if(!pack_feof(f))
22036 {
22037
2/4
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
2767 if(!p_mgetl(&section_id,f))
22038 {
22039 return qe_invalid;
22040 }
22041 2767 }
22042 }
22043 }
22044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 }
22045 else
22046 {
22047
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22048
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22049
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22050
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22051
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22052
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22053
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22054
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22055
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22056
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22057
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22058
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22059
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22060
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22061
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22062
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22063
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22064
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22065 };
22066
22067
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
140 for (auto& [desc, section_id, fn] : hardcoded_sections)
22068 {
22069 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22070 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22071 // read all the sections even if requested to skip some.
22072 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22073 // {
22074 // if (retval == qe_cancel)
22075 // continue;
22076 // checkstatus(retval);
22077 // }
22078
22079
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22080
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22081
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22082
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22083
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22084 }
22085
22086
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22087 {
22088
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22089
22090
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22091 {
22092 2048 int32_t type=DMaps[i].type&dmfTYPE;
22093
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22094
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22095 2048 }
22096 4 }
22097
22098
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22099
22100
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22101 4 setupsfx();
22102
22103
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22104
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22105
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22106
22107 129 init_spritelists();
22108
22109 // check data
22110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(f)
22111 {
22112 129 pack_fclose(f);
22113 129 }
22114 129 clear_quest_tmpfile();
22115
22116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!oldquest)
22117 {
22118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(exists(tmpfilename))
22119 {
22120 delete_file(tmpfilename);
22121 }
22122 129 }
22123
22124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(fixffcs && combosread && mapsread)
22125 {
22126 for(int32_t i=0; i<map_count; i++)
22127 {
22128 for(int32_t j=0; j<MAPSCRS; j++)
22129 {
22130 for(int32_t m=0; m<32; m++)
22131 {
22132 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22133 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22134 }
22135 }
22136 }
22137 }
22138
22139
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 29 times.
129 if(get_qr(qr_CONTFULL_DEP))
22140 {
22141 29 set_qr(qr_CONTFULL_DEP, 0);
22142 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22143 29 zinit.cont_heart=100;
22144 29 zinit.start_heart=zinit.hc;
22145 29 }
22146
22147 129 box_out("Done.");
22148 129 box_eol();
22149 129 box_end(false);
22150
22151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_header))
22152 {
22153 129 memcpy(Header, &tempheader, sizeof(tempheader));
22154 129 }
22155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_zinfo))
22156 {
22157 129 ZI.copyFrom(tempzi);
22158 129 }
22159
22160
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_maps))
22161 {
22162 map_count=old_map_count;
22163 }
22164
22165
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
22166 {
22167 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22168 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22169 }
22170
22171
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
22172 {
22173 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22174 }
22175
22176 //Debug FFCore.quest_format[]
22177 129 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22178 129 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22179 129 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22180 129 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22181 129 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22182 129 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22183 129 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22184 129 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22185 129 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22186 129 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22187 129 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22188 129 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22189 129 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22190 129 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22191 129 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22192 129 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22193 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22194 129 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22195 129 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22196 129 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22197 129 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22198 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22199 129 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22200 129 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22201 129 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22202 129 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22203 129 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22204 129 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22205 129 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22206 129 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22207 //Print metadata for versions under 2.10 here. Bleah.
22208
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if( FFCore.quest_format[vZelda] < 0x210 )
22209 {
22210 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22211
22212
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22213 {
22214 case 0x193:
22215 {
22216 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22217 }
22218 case 0x192:
22219 {
22220 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22221 }
22222 case 0x190:
22223 {
22224 4 zprint2("Last saved in ZC Editor Version: 1.90");
22225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22226 4 else zprint2("\n");
22227 4 break;
22228 }
22229 case 0x188:
22230 {
22231 zprint2("Last saved in ZC Editor Version: 1.88");
22232 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22233 else zprint2("\n");
22234 break;
22235 }
22236 case 0x187:
22237 {
22238 zprint2("Last saved in ZC Editor Version: 1.87");
22239 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22240 else zprint2("\n");
22241 break;
22242 }
22243 case 0x186:
22244 {
22245 zprint2("Last saved in ZC Editor Version: 1.86");
22246 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22247 else zprint2("\n");
22248 break;
22249 }
22250 case 0x185:
22251 {
22252 zprint2("Last saved in ZC Editor Version: 1.85");
22253 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22254 else zprint2("\n");
22255 break;
22256 }
22257 case 0x184:
22258 {
22259 zprint2("Last saved in ZC Editor Version: 1.84");
22260 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22261 else zprint2("\n");
22262 break;
22263 }
22264 case 0x183:
22265 {
22266 zprint2("Last saved in ZC Editor Version: 1.83");
22267 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22268 else zprint2("\n");
22269 break;
22270 }
22271 case 0x182:
22272 {
22273 zprint2("Last saved in ZC Editor Version: 1.82");
22274 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22275 else zprint2("\n");
22276 break;
22277 }
22278 case 0x181:
22279 {
22280 zprint2("Last saved in ZC Editor Version: 1.81");
22281 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22282 else zprint2("\n");
22283 break;
22284 }
22285 case 0x180:
22286 {
22287 zprint2("Last saved in ZC Editor Version: 1.80");
22288 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22289 else zprint2("\n");
22290 break;
22291 }
22292 default:
22293 {
22294 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22295 }
22296 }
22297 4 }
22298
22299 129 return qe_OK;
22300
22301 invalid:
22302 box_out("error.");
22303 box_eol();
22304 box_end(true);
22305
22306 if(f)
22307 {
22308 pack_fclose(f);
22309 }
22310
22311 if(!oldquest)
22312 {
22313 if(exists(tmpfilename))
22314 {
22315 delete_file(tmpfilename);
22316 }
22317 }
22318
22319 return qe_invalid;
22320
22321 129 }
22322
22323 129 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22324 {
22325 129 const char* basename = get_filename(filename);
22326 129 zapp_reporting_add_breadcrumb("load_quest", basename);
22327 129 zapp_reporting_set_tag("qst.filename", basename);
22328
22329 129 loading_qst_name = filename;
22330 129 loading_qst_num = qst_num;
22331 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22332 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22333
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!is_ci())
22334 loadquest_report = report;
22335 129 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22336 129 load_tmp_zi = NULL;
22337 129 loading_qst_name = NULL;
22338 129 loadquest_report = false;
22339 129 loading_qst_num = 0;
22340
22341 129 zapp_reporting_set_tag("qst.title", Header->title);
22342 129 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22343
22344 129 return ret;
22345 }
22346